1

AccessToken を取得しようとすると、次のエラーが発生します。

/MicrosoftGraph/Authorise?error=access_denied&error_description=AADSTS65005%3a+The+client+application+has+requested+access+to+resource+%27https%3a%2f%2fgraph.microsoft.com%2f%27.+This+request+ has+failed+because+the+client+has+not+specified+this+resource+in+its+requiredResourceAccess+list.%0d%0aTrace+ID%3a+7cd46ad3-d294-41ad-98ec-6ef06db7a0db%0d%0a相関+ID%3a+4e2a6d3b-b3dd-4a98-b36d-550d8f8c3382%0d%0aタイムスタンプ%3a+2016-01-27+10%3a40%3a12Z

どちらが... graph.microsoft.comクライアントがrequiredResourceAccessリストでこのリソースを指定していないため、この要求は失敗しました

Azure Active Directory のマルチテナント アプリケーションです。メール ID の 1 つで正常にログインできますが、別の ID ではログインできません。

どこが間違っていますか?私は何が欠けていますか?

コードスニペット:

public ActionResult Login() {
    ....
Uri authUri = authContext.GetAuthorizationRequestURL(
            MicrosoftGraphSettings.O365UnifiedAPIResource,
            MicrosoftGraphSettings.ClientId,
            loginRedirectUri,
            UserIdentifier.AnyUser,
            null);
string authUriAsString = authUri.ToString();
return Redirect(authUriAsString);
}

public async Task<ActionResult> Authorise()
{
    Uri loginRedirectUri = new Uri(Url.Action("Authorise", "MicrosoftGraph", null, Request.Url.Scheme));
    var authContext = new AuthenticationContext(MicrosoftGraphSettings.AzureADAuthority);

    var authResult = await authContext.AcquireTokenByAuthorizationCodeAsync(
            Request.Params["code"],                                             
            loginRedirectUri,                                               
            new ClientCredential(MicrosoftGraphSettings.ClientId, MicrosoftGraphSettings.ClientSecret), 
            MicrosoftGraphSettings.O365UnifiedAPIResource);
}

私は次のことを試しました

public static string O365UnifiedAPIResource = @"https://graph.microsoft.com/";
//public static string O365UnifiedAPIResource = @"https://graph.windows.net/"; 

2 番目のものを使用すると、認証は成功しますが、既存のコードを使用して OneDrive for business アカウントのファイルのリストにアクセスしたり、テキスト ファイルを作成したりするたびに、API 呼び出しの実行中に Unauthorized 例外がスローされます。

4

1 に答える 1

0

このエラー メッセージは、アプリケーションに "Microsoft Graph" ( https://graph.microsoft.com/ ) リソースに対する委任されたアクセス許可がないことを示しています。

Azure 管理ポータル ( https://manage.windowsazure.com ) を使用して、そのリソースの委任されたアクセス許可を構成してください。アプリを検索 -> 構成 -> 「他のアプリケーションへのアクセス許可」 -> 「アプリケーションの追加」 -> 「Microsoft Graph」を選択します。

「 https://graph.windows.net/ 」のトークンを取得できるため、アプリケーションには「Windows Azure Active Directory」リソースに対して構成されたアクセス許可が既にありますが、これは「Microsoft Graph」とは異なるリソースです。

于 2016-01-27T19:58:25.240 に答える