我有一个与OneNote一起使用了多年的应用程序,但是最近用户在保存新页面时抱怨间歇性问题。经过一些调试后,我们发现OneNote的API返回带有以下主体的401未经授权的响应:
{
"error":{
"code":"40001",
"message":"The request does not contain a valid authentication token.",
"@api.url":"https://aka.ms/onenote-errors#C40001"
}
}
当然,我们所有的请求都带有正确的Authorization: Bearer J...X
标头发送。如果我们多次重试失败的请求,则最终可以正常通过。
我们正在使用以下OAuth端点:https://login.live.com/oauth20_authorize.srf
这些是我们的范围:wl.basic, wl.signin, wl.offline_access, office.onenote_create, office.onenote_update_by_app
以下是获取用户笔记本的示例请求:
第一次尝试:
[~]$ curl -XGET -H 'Authorization: Bearer Ew...I=' "https://www.onenote.com/api/v1.0/notebooks?\$select=id,name,userRole,isDefault&\$expand=sections,sectionGroups"
{
"error": {
"code": "40001",
"message": "The request does not contain a valid authentication token.",
"@api.url": "https://aka.ms/onenote-errors#C40001"
}
}
第二次尝试:
[~]$ curl -XGET -H 'Authorization: Bearer Ew...I=' "https://www.onenote.com/api/v1.0/notebooks?\$select=id,name,userRole,isDefault&\$expand=sections,sectionGroups"
{
"@odata.context":"https://www.onenote.com/api/v1.0/$metadata#me/notes/notebooks(id,name,userRole,isDefault,sections,sectionGroups)","value":[
{
"id":"0-123123E123123123!831","name":"Jacket's Notebook","userRole":"Owner","isDefault":true,"sections@odata.context":"https://www.onenote.com/api/v1.0/$metadata#me/notes/notebooks('0-123123E123123123%21831')/sections","sections":[
{
"id":"0-123123E123123123!833","self":"https://www.onenote.com/api/v1.0/me/notes/sections/0-123123E123123123!833","createdTime":"2019-10-08T08:42:38.043Z","name":"Quick Notes","createdBy":"Jacket","lastModifiedBy":"Jacket","lastModifiedTime":"2019-10-08T09:59:26.173Z","isDefault":true,"pagesUrl":"https://www.onenote.com/api/v1.0/me/notes/sections/0-123123E123123123!833/pages","size":0
}
],"sectionGroups@odata.context":"https://www.onenote.com/api/v1.0/$metadata#me/notes/notebooks('0-123123E123123123%21831')/sectionGroups","sectionGroups":[
]
}
]
}
在没有任何更改的情况下,我们得到两个不同的响应。它看起来很像限速,尽管我们并没有发出太多请求来触发这样的事情,并且错误明确指出这是令牌的问题。但是令牌是相同的,并且在请求之间没有更新。
我现在被困住了。请帮忙!