Azure AD Graph 与 Microsoft Graph 应用程序授权令牌

Azure AD Graph vs Microsoft Graph App Authorization Tokens

我有一个应用程序当前正在使用 Azure AD Graph API。我想开始将应用程序迁移到 Microsoft Graph。但是,我想重复使用不记名令牌来访问 Azure AD Graph API 和 Microsoft Graph API。

我怎样才能做到这一点?目前看来,应用程序似乎必须分别在不同的门户网站上针对不同的 api 进行注册。

it seems as if the apps must be registered in different portals for the different api's respectively

这与我的经验不符。我已经在 Azure Active Directory 中注册了我的应用程序。

使用 Azure 门户,我可以获得 Microsoft Graph Api 和 Windows Azure Active Directory API.

的权限

i would like to reuse the bearer tokens for hitting both the Azure AD Graph API and Microsoft Graph API.

您不能对 Azure AD Graph API 和 Microsoft Graph API 使用相同的令牌。

在我的代码中,我通过以下调用收到访问令牌:

AuthenticationResult result = await authContext.AcquireTokenByAuthorizationCodeAsync(
                authorizationCode,
                redirectUri,
                CreateClientCredential(),
                resourceString
            );

对于 AD Graph API,resourceString 参数是 https://graph.windows.net/,对于 Microsoft Graph API。

https://graph.microsoft.com

它们是不同的资源,因此您必须管理两个令牌,为每个 API 调用应用适当的令牌。