azure-active-directorymicrosoft-graph-apiazure-ad-graph-apimicrosoft-graph-onenote

Accessing onenote via API MS graph


I've read lots of docs and different posts, but I can't get the right access token to read my own OneNote via api.

BUT:

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'
}

Perhaps somebody could give me a clue what I'm doing wrong ? :)

Sample request via graph explorer: https://graph.microsoft.com/v1.0/users/{my_username}@outlook.com/onenote/sections

Permissions in app (azure portal) screenshot

Permissions in graph explorer screenshot


Solution

  • Notes.Read.All and Notes.readWrite.All are valid for Work or school accounts only. Please refer this document.