Microsoft Graph API 访问令牌验证失败

Red*_*man 5 microsoft-graph-api

我使用这个 URL 来获取 id_token:

https://login.microsoftonline.com/common/oauth2/authorize?
response_type=id_token%20code&
client_id=MY_CLIENT_GUID_ID_IN_HERE&
redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fopenid%2Freturn&nonce=alfaYYCTxBK8oypM&
state=6DnAi0%2FICAWaH14e
Run Code Online (Sandbox Code Playgroud)

这个返回结果是这样的

http://localhost:3000/auth/openid/return?
code=AAA_code_in_here&
id_token=eyJ0eXAi_xxxx_yyyy_in_here&
state=6DnAi0%2FICAWaH14e&
session_state=xxxx_guid_xxxxx
Run Code Online (Sandbox Code Playgroud)

然后我使用id_token来查询 Graph(使用 POST man) 用于查询组的图形 API

我已经看到这篇文章InvalidAuthenticationToken 和 CompactToken 问题 - Microsoft Graph using PHP Curl但没有意义。

Mar*_*eur 4

OATH 2.0 需要多个步骤。第一个请求返回 OAUTH 代码。下一步是将 OATUH 代码转换为承载令牌。这是您在这里缺少的步骤。

我还建议使用v2 Endpoint,它更容易使用(特别是使用 Graph)。我编写了v2 Endpoint Primer,它介绍了整个过程,可能也会有所帮助。