Python Microsoft Graph access onenote as deamon服务返回无效范围

Python Microsoft Graph access onenote as deamon服务返回无效范围,python,microsoft-graph-api,Python,Microsoft Graph Api,我正在尝试以deamon服务的形式从组织内的用户访问onenote页面,因此用户不会登录,这将是一个正在运行的后台服务 我或多或少地遵循了本教程: 我已经设置了必要的API权限,它们已经由管理员授予。 然后我请求一个运行良好的OAuth令牌。然后我发送一个Onenote页面请求 import requests payload = { 'client_id': '<my_client_id_is_here>', 'scope': 'https://graph.mic

我正在尝试以deamon服务的形式从组织内的用户访问onenote页面,因此用户不会登录,这将是一个正在运行的后台服务

我或多或少地遵循了本教程:

我已经设置了必要的API权限,它们已经由管理员授予。

然后我请求一个运行良好的OAuth令牌。然后我发送一个Onenote页面请求

import requests

payload = {
    'client_id': '<my_client_id_is_here>',
    'scope': 'https://graph.microsoft.com/.default',
    'client_secret': '<my_client_secret_is_here>',
    'grant_type': 'client_credentials'
},

 tenant_id = "<my_tenant_id_is_here>"

response = requests.post(
    url='https://login.microsoftonline.com/{0}/oauth2/v2.0/token'.format(
        tenant_id
    ),
    data=payload 
)
token = json.loads(response.content)

test_url = 'https://graph.microsoft.com/v1.0/sites/<my-sharepoint-site-id>/onenote/sections/<my-onenote-section-id>/pages?top=100'


response = requests.get(
    url=test_url,
    headers={
        'Authorization': 'Bearer ' + token['access_token']
    }
)
print(response.content)
   

我已尝试将
范围
更改为
'scope':'https://graph.microsoft.com/notes.readwrite.all“,
但是令牌请求不起作用。解决了错误消息“范围参数无效”时,我意外选择了旧版onenote API端点作为权限,而不是尝试使用的Microsoft Graph onenote端点。

已解决,我无意中选择了旧版onenote API端点作为权限,而不是尝试使用的Microsoft Graph onenote端点

{
    "error": {
        "code": "40004",
        "message": "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",
            "innerError": {
            "date": "2020-08-18T06:17:51",
            "request-id": "1042af2a-ddc8-4c72-84b2-56f0079d6174"
        }
    }
}