使用 azuread v2.0 和个人帐户访问 /me 端点

Accessing /me endpoint with azuread v2.0 and personal accounts

我正在尝试使用 Azure AD v2.0 通过 Graph API 访问“/me”中的个人帐户信息,但我收到以下错误。它适用于组织帐户。

{
  "error": {
    "code": "UnknownError",
    "message": "{\"Status\":500,\"Message\":\"All the offeractions povided in the property bag cannot be validated for the token.\u000d\u000a\"}",
    "innerError": {
      "request-id": "39e23062-80ad-4872-86a7-39f5a5d928ce",
      "date": "2017-02-23T15:35:06"
    }
  }
}

我有权限User.ReadBasic.All

范围User.ReadBasic.All 授予代表登录用户读取组织中所有用户的基本配置文件的权限。只有 Azure AD 帐户支持此范围。如果您只想读取 Microsoft 帐户的用户配置文件,您可以使用范围 User.Read 。以下代码流程步骤供您参考:

获取授权码:

Get : https://login.microsoftonline.com/common/oauth2/v2.0/authorize?response_type=code&client_id=<client id>&redirect_uri=http%3A%2F%2Flocalhost%3A16468%2F&scope=https%3A%2F%2Fgraph.microsoft.com%2FUser.Read&state=af0ifjsldkj&nonce=n-0S6_WzA2Mj

然后获取令牌:

POST https://login.microsoftonline.com/common/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded


grant_type=authorization_code&code=<code>&state=af0ifjsldkj&redirect_uri=http%3A%2F%2Flocalhost%3A16468%2F&client_id=<client id>&client_secret=<client secret>