MSAL.NET AzureAD用户的名字和姓氏

时间:2018-11-05 05:43:16

标签: uwp azure-active-directory microsoft-graph msal

我正在使用下面的代码通过Microsoft.Identity.Client(MSAL.NET)从UWP应用向AzureAD进行身份验证。我不确定如何获取基本信息,例如用户的名字和姓氏。 AuthenticationResult msalar似乎没有透露。

从此处获取基本AzureAD用户详细信息的最佳方法是什么?

PublicClientApplication pca = new PublicClientApplication(clientId)
{
    RedirectUri = redirectUri
};
string[] scopes = { resourceId + "/user_impersonation" };
var users = await pca.GetAccountsAsync();
var user = users.FirstOrDefault();
AuthenticationResult msalar = await pca.AcquireTokenAsync(
    scopes, user, UIBehavior.ForceLogin, "domain_hint=test.net");

我也曾尝试使用Graph API获取上面的信息以及照片,但是我使用来自上方msalar的令牌对此请求得到了未经授权的错误:
https://graph.microsoft.com/beta/users/{userid}/photo/$value

0 个答案:

没有答案
相关问题