我有一个Web和一个使用ADAL库调用Web的UI应用程序。
在将应用程序注册到Azure时,我已经为Web和UI应用程序提供了DELEGATED PERMISSIONS (Read directory data)。

我在Web中有下面的代码来保存登录用户的令牌,
private void ConfigureAuthentication(IAppBuilder app)
{
app.UseWindowsAzureActiveDirectoryBearerAuthentication(
new WindowsAzureActiveDirectoryBearerAuthenticationOptions
{
Tenant = ConfigurationManager.AppSettings["ida:Tenant"],
TokenValidationParameters = new TokenValidationParameters { SaveSigninToken = true, ValidAudience = ConfigurationManager.AppSettings["ida:Audience"] }
});
}现在在Web控制器中,我试图获得令牌来使用下面的代码访问Microsoft AD Graph,
var bootstrapContext = ClaimsPrincipal.Current.Identities.First().BootstrapContext as System.IdentityModel.Tokens.BootstrapContext;
string userName = "test@onmicrosoft.com";
string userAccessToken = bootstrapContext.Token;
UserAssertion userAssertion = new UserAssertion(bootstrapContext.Token, "urn:ietf:params:oauth:grant-type:jwt-bearer", userName);
var authContext = new AuthenticationContext(string.Format(CultureInfo.InvariantCulture, aadInstance, tenant));
var clientCred = new ClientCredential(clientId, appKey);
var result = await authContext.AcquireTokenAsync("https://graph.windows.net", clientCred, userAssertion);
accessToken = result.AccessToken;上面的代码给出了令牌,但是作用域值在下面,
`scp: "User.Read"`问题-为什么令牌不提供目录访问(Directory.Read.All),因为我已经设置了目录访问?
`scp: "Directory.Read.All User.Read"`更新:
我缺少DELEGATED PERMISSIONS下读取目录数据的授予权限。在给Grant Permission之后,我能够获得scp: "Directory.Read.All User.Read"作用域的令牌

发布于 2018-03-26 02:39:53
如果我正确理解,您希望使用Microsoft,而不是。
然而,基于您在这个问题中发布的屏幕截图是一个v1 enpoint AAD应用程序,它对您试图接近的Microsoft没有任何作用。因此,无论您在这个应用程序上更改了什么,结果都应该是相同的。我建议您在v2 enpoint中注册https://apps.dev.microsoft.com/应用程序
这里是文件,它展示了如何获得使用MicrosoftGraph时的令牌。
希望这能有所帮助!
https://stackoverflow.com/questions/49475501
复制相似问题