我正在尝试使用客户端凭证流获取服务主体的组成员关系。我有以下代码:
var graphServiceClient = new Microsoft.Graph.GraphServiceClient(new Microsoft.Graph.DelegateAuthenticationProvider(async (requestMessage) =>
{
var authResult = await _confidentialClientApp.AcquireTokenForClient(new string[] { "https://graph.microsoft.com/.default" }).ExecuteAsync();
requestMessage.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", authResult.AccessToken);
}));
var groupMembership = await graphServiceClient.ServicePrincipals[userData.UniqueId].MemberOf.Request().GetAsync();
这回报:groupMembership.CurrentPage[0]。Id,但没有填充其他属性,包括我感兴趣的groupMembership.CurrentPage[0].DisplayName
我需要返回DisplayName以及id,我如何做到这一点?
解决方案是给应用程序注册Group.Read.All的权限,然后在groupMembership
中填充显示名。