Accessing OneNote pages using MSAL/Graph REST API results in error code 403.

Little Capa 0 Zuverlässigkeitspunkte
2025-01-02T10:47:23.87+00:00

Summary:
I have access to OneNote objects via the GRAPH Rest API. Although I am using the same access_token and the same scopes, I am able to access all of my notebooks and sections, but not my pages. Any attempt to access Pages always results in a 403 error.**
Details:**
I am currently developing a OneNote library. This library is intended to provide access to my OneNote Notebooks, Sections, and Pages.

To achieve this, I registered an app in the Azure Portal with the scope "Notes.ReadWrite.All."

In my library, I use the following configuration:

class DefaultConfig:
    CLIENT_ID = "xxx"
    AUTHORITY = "https://login.microsoftonline.com/common"
    SCOPES = [
        "Notes.ReadWrite.All",
        "Notes.Read.All",
        "Notes.Create",
        "User.Read"
    ]
    GRAPH_API_BASE_URL = "https://graph.microsoft.com/v1.0"
    NOTEBOOKS = "/me/onenote/notebooks"
    SECTIONS = "/me/onenote/notebooks/{notebook-id}/sections"
    PAGES = "/me/onenote/sections/{section-id}/pages"

Instead of "v1.0" I also tried "beta". But this didn't change anything.

For authentication, I use the MSAL library:

self.app = msal.PublicClientApplication(
                client_id=config['CLIENT_ID'],
                authority=config['AUTHORITY']
            )
result = self.app.acquire_token_interactive(
                scopes=self.config['SCOPES']
            )

Access to the OneNote objects is done via requests:

headers = {"Authorization": f"Bearer {self.access_token}"}
response = requests.get(url, headers=headers)

The handling is the same for accessing Notebooks, Sections, and Pages. Access to Notebooks and Sections works fine, but for Pages, I consistently receive error code 403.

2025-01-02 11:45:27,866 - ERROR - Request failed for URL https://graph.microsoft.com/v1.0/me/onenote/sections/0-66899B659FC7C342!171123/pages: 403 Client Error: Forbidden for url: https://graph.microsoft.com/v1.0/me/onenote/sections/0-66899B659FC7C342!171123/pages
Office
Office
Eine Sammlung von Microsoft-Produktivitätssoftware, die gängige Geschäftsaufgaben unterstützt, darunter Textverarbeitung, E-Mail, Präsentationen sowie Datenverwaltung und -analyse.
83 Fragen
Active Directory
Active Directory
Eine Reihe verzeichnisbasierter Technologien, die in Windows Server enthalten sind
31 Fragen
Entwicklung
Entwicklung
Der Vorgang der Erforschung, Produktisierung und Optimierung neuer oder vorhandener Technologien.
14 Fragen
{count} Stimmen

Ihre Antwort

Fragesteller*innen können Antworten als akzeptierte Antworten markiert werden, wodurch Benutzer*innen wissen, dass diese Antwort das Problem gelöst hat.