通过 API MS 图访问 onenote

Accessing onenote via API MS graph

我已经阅读了很多文档和不同的帖子,但我无法通过 api 获得正确的访问令牌来阅读我自己的 OneNote。

但是:

The OAuth token provided does not have the necessary scopes to complete the request. Please make sure you are including one or more of the following scopes: Notes.ReadWrite.All,Notes.Read.All

token_request_data = {
    'client_id': 'id from my app',     # also tried 'common'
    'scope': 'https://graph.microsoft.com/.default',  # other scopes cause errors
    'client_secret': 'secret from my app',
    'grant_type': 'client_credentials'
}

也许有人可以告诉我我做错了什么? :)

通过图形资源管理器的示例请求: https://graph.microsoft.com/v1.0/users/{my_username}@outlook.com/onenote/sections

Permissions in app (azure portal) screenshot

Permissions in graph explorer screenshot

Notes.Read.AllNotes.readWrite.All 仅对工作或学校帐户有效。请参考这个 document.