Azure active directory 无法在azure graph API中使用RoleManagement API终结点获取
我正在尝试使用azure Graph API获取具有特定角色的用户。下面是我如何生成authToken的代码片段Azure active directory 无法在azure graph API中使用RoleManagement API终结点获取,azure-active-directory,microsoft-graph-api,Azure Active Directory,Microsoft Graph Api,我正在尝试使用azure Graph API获取具有特定角色的用户。下面是我如何生成authToken的代码片段 AuthenticationContext authenticationContext = new AuthenticationContext(_authString, false); ClientCredential clientCred = new ClientCredential(_clientId, _clientSecret);
AuthenticationContext authenticationContext = new AuthenticationContext(_authString, false);
ClientCredential clientCred = new ClientCredential(_clientId, _clientSecret);
AuthenticationResult authenticationResult;
if (_authenticationResult == null || true == CanAcquireToken)
{
authenticationResult = authenticationContext.AcquireTokenAsync(_resAzureGraphAPI, clientCred).GetAwaiter().GetResult();
_authenticationResult = authenticationResult;
}
return _authenticationResult.AccessToken;
Graph API对我的应用程序拥有的权限列表的快照:
我阅读的目的是了解API端点以及相应appRegistration上Graph API所需的权限集
我已经为正在审查的应用程序提供了graph API所需的权限集。
但是,API请求
https://graph.microsoft.com/{{beta}}/roleManagement/directory/roleAssignments?$filter=roleDefinitionId eq '{{roleDefnId-Guid}}'
始终使用错误详细信息失败
访问令牌验证失败。无效观众
注意:生成的身份验证令牌正在成功地从“”提到的调用中获取我的信息您的应用程序的权限正确,
目录。ReadWrite。所有
应用程序权限都已足够。我还测试了你的代码,它工作得很好
确保代码中的\u resAzureGraphAPI
为https://graph.microsoft.com
(只需再次确认,我知道如果它是错误的,您将无法在注释中调用api
)。我可以用错误的问题重现您的问题,例如https://graph.windows.net
如果\u resAzureGraphAPI
正确,请在中解码您的令牌,请参见以下内容
您的应用程序的权限是正确的,
目录.ReadWrite。所有
应用程序权限都足够了。我还测试了你的代码,它工作得很好
确保代码中的\u resAzureGraphAPI
为https://graph.microsoft.com
(只需再次确认,我知道如果它是错误的,您将无法在注释中调用api
)。我可以用错误的问题重现您的问题,例如https://graph.windows.net
如果\u resAzureGraphAPI
正确,请在中解码您的令牌,请参见以下内容
您是如何生成令牌的?您能更新问题中的步骤吗?嘿,Joy,我已经用authToken生成代码片段编辑了我的帖子,以及我在应用程序BTW上为GraphAPI设置的权限列表,
https://graph.microsoft.com/{{beta}}/
应该是https://graph.microsoft.com/beta/
,您是否使用了正确的URL?我所指的整个URL是“eq'Guid'”。为此,我怀疑它将如何检查我所指的正确应用程序以检查我的答案、任何更新?您是如何生成令牌的?您能更新问题中的步骤吗?嘿,Joy,我已经用authToken生成代码片段编辑了我的帖子,以及我在应用程序BTW上为GraphAPI设置的权限列表,https://graph.microsoft.com/{{beta}}/
应该是https://graph.microsoft.com/beta/
,你使用的是正确的吗?我所指的整个URL是“eq'Guid'”。对于这一点,我怀疑它如何检查我所指的正确应用程序来检查我的答案,是否有任何更新?