【发布时间】:2019-11-06 18:33:17
【问题描述】:
我正在尝试使用 azure Graph API 来获取具有特定角色的用户。下面的代码 sn-p 作为我生成 authToken 的方式
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 对我的应用程序的权限列表快照: GraphAPI permissions on application
我阅读了https://docs.microsoft.com/en-us/graph/api/rbacapplication-list-roleassignments?view=graph-rest-beta&tabs=http 以了解 API 端点以及相应 appRegistration 上 Graph API 所需的一组权限。
我已为正在审核的应用程序提供了所需权限集的图形 API。 但是,API 请求
https://graph.microsoft.com/{{beta}}/roleManagement/directory/roleAssignments?$filter=roleDefinitionId eq '{{roleDefnId-Guid}}'
总是失败并显示错误详细信息
访问令牌验证失败。无效的观众
注意:生成的身份验证令牌已成功从“https://docs.microsoft.com/en-us/graph/api/approleassignment-get?view=graph-rest-beta&tabs=http”提到的调用中获取我的信息
【问题讨论】:
-
你是如何生成令牌的?您能否更新问题中的步骤?
-
嗨,Joy,已使用 authToken 生成代码 sn-p 和我在应用程序上为 GraphAPI 提供的权限列表编辑了我的帖子
-
顺便说一句,
https://graph.microsoft.com/{{beta}}/应该是https://graph.microsoft.com/beta/,你用对了吗? -
我所指的整个 URL 是“graph.microsoft.com/beta/roleManagement/directory/… eq 'Guid'” 我怀疑它如何检查我所指的正确应用程序
-
检查我的答案,有什么更新吗?
标签: azure-active-directory microsoft-graph-api