我正在关注this guide对 Microsoft Graph API 进行身份验证,并使用 Postman,我可以 POST
到 /token
端点,成功获取 token :
现在,复制该 token 并将其粘贴到 Authorization: Bearer {{token}}
中,我尝试向 https://graph.windows.net/my- 发出请求tenant/me?api-version=1.6/
,但我得到的回复是
{
"odata.error": {
"code": "Authentication_ExpiredToken",
"message": {
"lang": "en",
"value": "Your access token has expired. Please renew it before submitting the request."
},
"date": "2018-05-23T08:05:10",
"requestId": "f56bcd26-4314-41c6-81b6-e6540aa7b0ae",
"values": null
}
}
我刚刚创建的 token 怎么会过期?
最佳答案
我怀疑 token 是否已过期,该消息似乎已关闭。
您正在尝试使用 MS Graph API 的 token 调用 Azure AD Graph API。
将范围更改为 https://graph.windows.net/.default
,或调用 https://graph.microsoft.com/v1.0/me
。
此外,在使用客户端凭据流后,您无法调用 /me
端点。没有登录用户。您必须使用 /users/object-id-or-upn
关于oauth-2.0 - Microsoft Graph API 的访问 token 立即过期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50483154/