2017-05-05 3 views
1

Microsoft의 분산 문서에 약간 혼란 스럽습니다.Keyvault 인증 (REST API)

가 나는 것을 의미하는 응용 프로그램 (https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal)를 만든 지금이 :

  • 응용 프로그램 ID
  • 디렉토리 ID는

나는 푸른에서 KeyVault에 갔다 포털 및 응용 프로그램에 대한 사용 권한을 부여했습니다.

테스트 목적으로 CURL을 통해 테스트를 실행하려고합니다.

curl -d "grant_type=client_credentials&client_id=<removed_for_security>&client_secret=<removed_for_security>" https://login.microsoftonline.com/<removed_for_security>/oauth2/token 

이 토큰을 반환 :이를 위해 사용하고 기초는 다음 Microsoft 페이지 (https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-service-to-service#request-an-access-tokenhttps://docs.microsoft.com/en-us/rest/api/#create-the-request)

그래서, 내가 할 첫 번째 일은 다음 호출을 통해 토큰을 얻을이다.

curl -H "Authorization: Bearer <removed_for_security>” -vv https://<removed_for_security>.vault.azure.net/secrets/<removed_for_security>/<removed_for_security> 

난 그냥 "HTTP/1.1 401 권한"

답변

2

좋아, 그래서 내가 요청을 확인할 수 있습니다, 다시 어떤 내용을 얻을 :

I는 다음과 같이 그 토큰을 사용 (시도) 당신이하고있는 것은 유효합니다. 대부분은 API 버전을 잊어 버렸지 만, 문제는 API 버전이 아닙니다.

https://xxx.vault.azure.net/secrets/xxx/?api-version=2015-06-01 

이 URL이 작동하므로 토큰이 맞지 않습니다. 가장 쉬운 방법은 JWT.io로 이동하여 토큰을 붙여 넣은 다음 키 볼트가 예상하는 내용과 일치하는지 확인하는 것입니다. 아마 당신은 불일치가 있습니다.

+0

그래. API 버전을 잊어 버렸습니다. –

+0

이상한, API 버전을 제거했을 때 API 버전을 지정하는 것을 잊어 버렸다고 구체적으로 말한 적이 있습니다 ... @LittleCode – 4c74356b41

0

토큰을 요청할 자원을 지정해야합니다.

curl -d "grant_type=client_credentials&client_id=<removed_for_security>&client_secret=<removed_for_security>&resource=https://vault.azure.net" https://login.microsoftonline.com/<removed_for_security>/oauth2/token 

또한 api 버전을 추가하십시오.