我正在使用microsoft图形从活动目录获取用户数据。当我使用sdk时,我只得到关于用户的基本信息,例如。"displayName","mail","userPrincipalName","id“。其他所有东西都有空值。我在蔚蓝中的应用程序有权限查看信息。当我打开azure的所有权限时,结果是一样的。我怎样才能得到城市和乡村的信息?

发布于 2017-09-25 21:56:57
这是预期的行为,因为Microsoft端点返回User资源的默认属性集。
要返回附加属性,需要通过查询选项显式地请求它们。对于msgraph dotnet,可以指定如下附加属性:
var users = await graphClient.Users.Request().Select("companyName,city,country,contacts,contactFolders").GetAsync();另一种选择是以端点为目标。对于端点https://graph.microsoft.com/beta/users,以及默认属性,结果中至少将包括companyName、city、country。
下面的片段展示了如何将msgraph dotnet初始化为目标API beta版本:
_graphClient = new GraphServiceClient("https://graph.microsoft.com/beta",
new DelegateAuthenticationProvider(async (requestMessage) =>
{
// Passing tenant ID to the sample auth provider to use as a cache key
string accessToken = await _authProvider.GetUserAccessTokenAsync(userId);
// Append the access token to the request
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
})); https://stackoverflow.com/questions/46409490
复制相似问题