Skip to main content
The OneDrive resource talks to Microsoft OneDrive and SharePoint document libraries through the Microsoft Graph API. It authenticates with an OAuth2 bearer access token, optionally scoped to a specific drive.

Credentials

You need two things: an access token, and (for app-only tokens or SharePoint) a drive ID. Pick whichever token path fits.

Option A: Quick token (Graph Explorer)

Fastest way to try it. The token lasts about an hour, which is plenty for a test run.
  1. Open Graph Explorer and Sign in.
  2. Run any query (for example GET /me/drive) and consent when prompted.
  3. Open the Access token tab and copy the token.
This is a delegated token, so it works against your own /me/drive and you do not need a drive ID.

Option B: Repeatable token (app registration + device code)

Use this for scripted or CI runs.
  1. In the Microsoft Entra admin center, go to Identity -> Applications -> App registrations -> New registration. For a personal account, choose Accounts in any organizational directory and personal Microsoft accounts.
  2. Under Authentication -> Advanced settings, set Allow public client flows to Yes.
  3. Under API permissions -> Microsoft Graph -> Delegated, add Files.ReadWrite.All (add Sites.ReadWrite.All for SharePoint libraries).
  4. Run the device-code flow with your Application (client) ID:
App-only tokens (client-credentials flow) have no signed-in user, so /me/drive returns an error. With an app-only token you must pass a drive_id (or site_id). Delegated tokens (Options A and B) can use /me/drive with no drive ID.

Get your drive ID

Only needed for app-only tokens or to target a specific SharePoint library. With your token exported as TOKEN:
The drive ID looks like b!a1B2c3....

Set environment variables

Snapshots and version pinning rely on OneDrive/SharePoint version history, which is on by default. Older versions are only readable while the library retains them (the version cap is configurable, and an admin can disable versioning).
For Python configuration, see the Python OneDrive Setup guide.