Mircosoft Graphs API /common 与 /{{tenant}}

问题描述 投票:0回答:1

我在我的天蓝色电子邮件中创建了一个名为:[email protected] 的应用程序注册,并且我在其中配置了重定向 URI 和客户端密钥,并且还向该应用程序授予了 API 权限。

我在其他租户中创建了一个用户,并且厌倦了使用他的凭据登录我的应用程序,所以首先我使用以下网址登录

https://login.microsoftonline.com/{{tenantId}}/oauth2/v2.0/authorize?client_id={{clientId}}&response_type=code&redirect_uri={{RedirectURI}}&response_mode=query&scope={{Group.Read.All User.Read User.Read.All}}&state=abc

生成访问令牌后,我获得了以下权限列表:

Group.Read.All GroupMember.Read.All IdentityProvider.Read.All openid User.Read User.Read.All profile email

在 API 响应中 我能够使用 Microsoft Graph API

/groups
/me
,但在尝试调用
/users
端点时出现以下错误

{
    "error": {
        "code": "Authorization_RequestDenied",
        "message": "Insufficient privileges to complete the operation.",
        "innerError": {
            "date": "2024-05-09T14:57:11",
            "request-id": "eea77793-9d1f-4f36-80ec-4e1b479274c2",
            "client-request-id": "eea77793-9d1f-4f36-80ec-4e1b479274c2"
        }
    }
}

当我使用 /common 端点时,它也起作用。我能够成功调用 /me、/groups、/users 端点

感谢您的任何类型的支持。只是我需要了解 /common 与 /{{tenantId}} 之间的区别

pic 1

oauth-2.0 microsoft-graph-api
1个回答
0
投票

我建议您解码访问令牌(jwt.ms)并确保在目标租户中为请求的操作授予适当的权限(

User.Read.All
等)。

  • /common
    端点

    • 用于多租户应用程序,任何租户的用户都可以进行身份验证。
    • 获得的访问令牌可以在多个租户之间拥有更广泛的权限。
  • /{{tenantId}}
    端点

    • 仅针对特定租户进行身份验证。
    • 访问令牌的范围仅限于指定租户内的操作。
© www.soinside.com 2019 - 2024. All rights reserved.