Microsoft Graph API的访问令牌立即过期 [英] Access token for Microsoft Graph API is immediately expired

查看:167
本文介绍了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

这篇关于Microsoft Graph API的访问令牌立即过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆