Onedrive API 拒绝访问令牌(CompactToken 解析失败,错误代码:8004920A)
Onedrive API rejects access token (CompactToken parsing failed with error code: 8004920A)
希望我遗漏了一些非常简单的东西。根据 this documentation 获取访问令牌我需要点击以下 url:
https://login.live.com/oauth20_authorize.srf?client_id={client_id}&scope={scope}
&response_type=token&redirect_uri={redirect_uri}
到目前为止,这似乎是有效的,因为返回的 url 我得到包含
/#access_token=EwAYA61DBAAUcSSzo.......
根据上面的令牌流文档,
You can use the value of access_token to make requests to the OneDrive API.
根据 this 页,
Your app provides the access token in each request, through an HTTP header:
Authorization: bearer {token}
当 运行 curl 我给它我之前得到的确切令牌时,
curl -X GET \
https://graph.microsoft.com/v1.0/drive \
-H 'Authorization: Bearer EwAYA61DBAAUcSSzoTJJs.....
{
"error": {
"code": "InvalidAuthenticationToken",
"message": "CompactToken parsing failed with error code: 8004920A",
"innerError": {
"request-id": "8780c600-2b7f-45a0-b484-7eca9dfd2697",
"date": "2019-01-25T19:33:22"
}
}
}
为什么他们提供的令牌不起作用?
到目前为止我尝试过的:
- 改变 header
中承载的大小写
- 在 {}
中包装所述令牌
- 生成新令牌
- URL解码所述令牌
需要注意一件事:我收到的令牌是不是 JWT 令牌。谷歌搜索错误代码会出现几个 Stack Overflow 问题,这些问题似乎暗示图表 api 需要 JWT。如果是这种情况,我是否错过了获得它的步骤?
完成 Microsoft 帐户(OneDrive 个人)的身份验证流程后,您无法调用 Microsoft Graph API。
此外,不再推荐使用 Microsoft 帐户的授权过程according the docs,应使用 Microsoft Graph 开发新应用程序:
This topic contains information about authorizing an application using Microsoft accounts for OneDrive personal. However, this approach is no longer recommended. New applications should be developed using Microsoft Graph and follow the authorization process in Authorization and sign-in for OneDrive in Microsoft Graph.
希望我遗漏了一些非常简单的东西。根据 this documentation 获取访问令牌我需要点击以下 url:
https://login.live.com/oauth20_authorize.srf?client_id={client_id}&scope={scope}
&response_type=token&redirect_uri={redirect_uri}
到目前为止,这似乎是有效的,因为返回的 url 我得到包含
/#access_token=EwAYA61DBAAUcSSzo.......
根据上面的令牌流文档,
You can use the value of access_token to make requests to the OneDrive API.
根据 this 页,
Your app provides the access token in each request, through an HTTP header:
Authorization: bearer {token}
当 运行 curl 我给它我之前得到的确切令牌时,
curl -X GET \
https://graph.microsoft.com/v1.0/drive \
-H 'Authorization: Bearer EwAYA61DBAAUcSSzoTJJs.....
{
"error": {
"code": "InvalidAuthenticationToken",
"message": "CompactToken parsing failed with error code: 8004920A",
"innerError": {
"request-id": "8780c600-2b7f-45a0-b484-7eca9dfd2697",
"date": "2019-01-25T19:33:22"
}
}
}
为什么他们提供的令牌不起作用?
到目前为止我尝试过的:
- 改变 header 中承载的大小写
- 在 {} 中包装所述令牌
- 生成新令牌
- URL解码所述令牌
需要注意一件事:我收到的令牌是不是 JWT 令牌。谷歌搜索错误代码会出现几个 Stack Overflow 问题,这些问题似乎暗示图表 api 需要 JWT。如果是这种情况,我是否错过了获得它的步骤?
完成 Microsoft 帐户(OneDrive 个人)的身份验证流程后,您无法调用 Microsoft Graph API。
此外,不再推荐使用 Microsoft 帐户的授权过程according the docs,应使用 Microsoft Graph 开发新应用程序:
This topic contains information about authorizing an application using Microsoft accounts for OneDrive personal. However, this approach is no longer recommended. New applications should be developed using Microsoft Graph and follow the authorization process in Authorization and sign-in for OneDrive in Microsoft Graph.