2017-12-04 1 views
3

Microsoft Graph API에서 캘린더를 가져 오기 위해 호출 할 때 권한이 없으므로이 확인을 사용하여 액세스 토큰을 검색합니다.office365 그룹의 캘린더에 액세스 할 수 없습니다.

캘린더에서 HTTP 요청 가져 오기를 검색 할 때 인증 토큰이 인증되지 않은 호출의 결과로 생성되지 않는다고 생각합니다. 자격증 명을 보내고 더 많은 권한을 가진 더 우수한 토큰을 얻을 수 있도록 코드를 어떻게 변경합니까?

Azure 포털에서 응용 프로그램 권한이 올바르게 설정되지 않았는지 확인하기 위해 모든 권한을 부여했습니다.

AuthenticationContext authenticationContext = new AuthenticationContext(authString, false); 
ClientCredential clientCred = new ClientCredential(_azureAd_ClientId, _azureAd_SecretKey); 

string tokenResult; 

AuthenticationResult authenticationResult; 
try 
{ 
    authenticationResult = await authenticationContext.AcquireTokenAsync(_azureAd_GraphResource, clientCred); 
    var user = authenticationResult.UserInfo; 
    string_token = authenticationResult.AccessToken; 
    tokenResult = JsonConvert.SerializeObject(authenticationResult); 
} 
catch (Exception ex) 
{ 
    throw new Exception(ex.Message, ex.InnerException); 
} 
+0

'_azureAd_GraphResource'의 값은'https : // graph.microsoft.com'입니까? – juunas

+0

예, 끝 슬래시가 "https://graph.microsoft.com/" –

+0

예. 좋습니다. 앱 권한을 추가 했습니까? 클라이언트 자격 증명을 사용 중이므로 위임 된 권한은 여기에 적용되지 않습니다. 또한 해당 권한을 부여해야합니다. 포털의 권한 부여 버튼을 누릅니다. – juunas

답변

0

는 의견을 통해 읽기 당신이 응용 프로그램 당신이 다시 구성한 권한을 부여하기 위해 새로운 동의 확인 프롬프트를 실행해야 할 것으로 보인다. 이 응용 프로그램이 V1 인 경우 요청 끝에 prompt = admin_consent를 추가하면됩니다. V2 응용 프로그램 인 경우/adminconsent 끝점을 사용하는 것이 좋습니다. 그것에 대한 자세한 정보는 here입니다.

일반 관리자 승인에 대한 문서가 일반적으로 here입니다.

관련 문제