I’m trying to get a specific page data using the graph API.
If I try to run through https://developer.microsoft.com/en-us/graph/graph-explorer I can put it to work, also if I use the token generated there it also works fine in script.
But when I try to generate the code in the script and run myself I get a 404 error.
Here is the script:
from msal import ConfidentialClientApplication
authority = "https://login.microsoftonline.com/common"
#get connection to the API working
app = ConfidentialClientApplication(client_id, authority="https://login.microsoftonline.com/my-tenant-id", client_credential=client_secret)
result = app.acquire_token_for_client(['https://graph.microsoft.com/.default'])
if "access_token" in result:
print('Access Token: ', result["access_token"])
import requests
#response = requests.get("https://graph.microsoft.com/v1.0/users", headers={'Authorization': 'Bearer {}'.format(result["access_token"])})
response = requests.get("https://graph.microsoft.com/v1.0/users/myuser/onenote/pages/page-id/content", headers={'Authorization': 'Bearer '+result["access_token"]})
Actually getting out of ideas on what I might be missing.
Already checked all the permissions over and over again.
Any suggestion would be much appreaciated.