Outlook API invalid_token错误

Geo*_*ros 1 outlook-restapi

我正在尝试使用以下请求调用outlook API:

https://outlook.office.com/api/v2.0/me/calendars
GET
Authorization: Bearer [my fresh bearer token]
Run Code Online (Sandbox Code Playgroud)

登录和用户同意后,我成功从令牌端点检索了access_token.

但是,我尝试的每个请求都会使用以下标题返回401 Unauthorized(显示一个因为它看起来很奇怪):

WwwAuthenticate [HttpHeaderValueCollection]: {Bearer client_id="00000002-0000-0ff1-ce00-000000000000", trusted_issuers="00000001-0000-0000-c000-000000000000@*", token_types="app_asserted_user_v1 service_asserted_app_v1", authorization_uri="https://login.windows.net/common/oauth2/authorize", error="invalid_token", Basic Realm="", Basic Realm="", Basic Realm=""}
Run Code Online (Sandbox Code Playgroud)

如您所见,最后有错误="invalid_token"

此外,还有app_asserted_user_v1 service_asserted_app_v1

有没有我忘记激活或配置正确的东西?

编辑:我确实找到了这篇文章,但如果我添加像OP这样的资源参数,我得到"错误的请求"和这段代码:

AADSTS90100:不支持"资源"请求参数.

Geo*_*ros 5

好吧,我自己找到了答案,希望能帮助更多人:

问题甚至在此之前,在我将用户重定向到MS登录页面的步骤.

那时我曾经给它以下范围:

openid Calendars.ReadWrite offline_access profile

但是,Calendars.ReadWrite必须以其"完整"名称传递,其中包括:

https://outlook.office.com/Calendars.ReadWrite

HTH