简体   繁体   English

Microsoft Graph-获取MemberOf

[英]Microsoft Graph - Get MemberOf

I'm trying to access the groups a user is a member of using the Microsoft Graph API. 我正在尝试访问用户是使用Microsoft Graph API成员的组。 I'm facing an issue because I think my permissions are set correctly, however, when I sign into the app, I get the message : 我遇到了一个问题,因为我认为我的权限设置正确,但是,当我登录该应用程序时,出现了以下消息:

 AADSTS90093: Calling principal cannot consent due to lack of permissions. 

The weird thing is that I'm only asking for this permission scope : 奇怪的是,我只要求这个权限范围:

public static String[] ClientScope = { "User.Read", "User.ReadBasic.All", "Group.Read.All"}; 公共静态String [] ClientScope = {“ User.Read”,“ User.ReadBasic.All”,“ Group.Read.All”}};

What makes me confused is that if I sign in the Microsoft Graph explorer and go to https://graph.microsoft.com/v1.0/me/memberOf , I get the correct results. 让我感到困惑的是,如果我登录Microsoft Graph资源管理器并转到https://graph.microsoft.com/v1.0/me/memberOf ,我会得到正确的结果。 I got an admin to consent to the permissions I'm asking in the scope of course. 我得到了管理员同意,我当然要问的权限。

Has anyone encountered that issue ? 有人遇到过这个问题吗?

Any idea how I should correct that ? 知道我该如何纠正吗?

The memberOf API requires one of the following scopes: memberOf API需要以下作用域之一:

  • Directory.Read.All 目录全部读取
  • Directory.ReadWrite.All Directory.ReadWrite.All
  • Directory.AccessAsUser.All Directory.AccessAsUser.All

Regardless of which of these scopes you choose, they all will require administrative consent before a regular user can authorize them. 无论您选择这些范围中的哪一个,在常规用户对其进行授权之前,都需要获得管理许可。 To do this, you'll first need to have them go through the “Admin Consent” workflow. 为此,您首先需要让他们通过“管理员同意”工作流程。 This workflow requires an administrator but once complete any users of your application will have “admin consent” to the restricted scope. 此工作流程需要管理员,但是一旦完成,您的应用程序的任何用户都将获得受限范围的“管理员同意”。

For example, you would normally you would then authenticate users by redirecting them to 例如,通常您将通过将用户重定向到

https://login.microsoftonline.com/common/oauth2/authorize?<your params> . https://login.microsoftonline.com/common/oauth2/authorize?<your params>

Since this scope requires an Admin however, you fist need to obtain consent by first having an Admin authenticate by redirecting them to 由于此范围需要管理员,因此您首先需要获得管理员的同意,方法是先将管理员重定向到

https://login.microsoftonline.com/common/adminconsent?<yours params> . https://login.microsoftonline.com/common/adminconsent?<yours params>

Once an Admin grants consent, normal users will be able to use OAUTH to authenticate. 管理员授予同意后,普通用户将可以使用OAUTH进行身份验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM