【问题标题】:Graph API "get groups" on behalf of signed user results into 403 error with message":"Insufficient privileges to complete the operationGraph API "get groups" 代表签名用户导致 403 error with message":"Insufficient permissions to complete the operation
【发布时间】:2021-09-18 04:31:12
【问题描述】:

用例:代表登录用户使用 Authorization_code 流调用https://graph.microsoft.com/v1.0/groups

具有 OAuth2Session 范围https://graph.microsoft.com/.default

oauth_session = OAuth2Session(clientid=clientid, state=session['oauth_state'], client=client,scope="https://graph.microsoft.com/.default")

access_token 具有范围:“User.Read”。我不知道如何操作这个范围!

api 客户端 具有所有必需的委派权限(GroupMember.Read.All、Group.Read.All、Directory.Read.All、Group.ReadWrite.All、Directory.ReadWrite.All、Directory. AccessAsUser.All) 如此处所述: https://docs.microsoft.com/de-de/graph/api/group-get?view=graph-rest-1.0&tabs=http

我也尝试在 OAuth2Session 中设置范围“Group.Read.All”,但没有帮助。

oauth_session = OAuth2Session(clientid=clientid, state=session['oauth_state'], client=client,scope="https://graph.microsoft.com/Group.Read.All")

以下请求使用与上述用例相同的 oauth 配置正常工作: https://graph.microsoft.com/v1.0/me(这里我得到登录的用户ID), https://graph.microsoft.com/v1.0/users/{id}/getMemberGroups(这里我得到一个组列表,用户所属)

使用https://graph.microsoft.com/v1.0/groupshttps://graph.microsoft.com/v1.0/groups/{id} 我的目标是获取组的显示名称或登录用户的groupid 的显示名称。 我的问题:是否有可能通过带有授权流(WebApplicationClient)的图形 api 或仅通过 BackendApplicationClient(客户端凭据流)获取登录用户的组。如果是,我该如何解决我的范围问题?

【问题讨论】:

    标签: python microsoft-graph-api access-token scopes


    【解决方案1】:

    403 错误表示令牌不必更正权限。

    对于授权代码流,您需要询问 https://graph.Microsoft.com/Group.Read.All 范围。

    我总是使用jwt.ms,它允许我检查令牌并查看哪些声明可用。

    【讨论】:

      猜你喜欢
      • 2020-10-17
      • 2016-02-05
      • 1970-01-01
      • 2018-05-11
      • 1970-01-01
      • 2013-03-12
      • 1970-01-01
      • 2020-12-16
      • 1970-01-01
      相关资源
      最近更新 更多