Microsoft Graph API的访问令牌立即过期
我正在遵循本指南进行身份验证Microsoft Graph API,并使用邮递员,我可以POST
到/token
端点成功获得令牌:
I'm following this guide to authenticate to the Microsoft Graph API, and using Postman I can POST
to the /token
endpoint successfully get a token:
现在,复制该令牌并将其粘贴到Authorization: Bearer {{token}}
中,我尝试向https://graph.windows.net/my-tenant/me?api-version=1.6/
发出请求,但是我得到的答复是
Now, copying that token and pasting it into Authorization: Bearer {{token}}
, I try to make a request to https://graph.windows.net/my-tenant/me?api-version=1.6/
, but the response I get says
{
"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
}
}
我刚刚创建的令牌如何过期?
How can the token I just created be expired?
我怀疑令牌已过期,消息似乎不存在.
I doubt the token is expired, the message seems off.
您正在尝试使用MS Graph API的令牌调用Azure AD Graph API.
将您的范围更改为https://graph.windows.net/.default
,或致电https://graph.microsoft.com/v1.0/me
.
You are trying to call Azure AD Graph API with a token for MS Graph API.
Change your scope to https://graph.windows.net/.default
, or call https://graph.microsoft.com/v1.0/me
.
此外,使用客户端凭据流后,您将无法调用/me
端点.没有登录的用户.您必须使用/users/object-id-or-upn
Also, you cannot call the /me
endpoint after using client credentials flow. There is no signed in user. You have to use /users/object-id-or-upn