Credentials
You need an access token and, for app-only auth or a drive other than the signed-in user’s default, one explicit drive selector. 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.- Open Graph Explorer and Sign in.
- Run any query (for example
GET /me/drive) and consent when prompted. - Open the Access token tab and copy the token.
/me/drive and you do
not need a drive ID.
Option B: Interactive device-code token
Use this to obtain a delegated token through your own app registration; the initial sign-in makes it a development bootstrap, not an unattended credential.- 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.
- Under Authentication -> Advanced settings, set Allow public client flows to Yes.
- Under API permissions -> Microsoft Graph -> Delegated, add
Files.Readfor your own drive orFiles.ReadWritefor writes. Other drives or SharePoint may require the correspondingFiles.*.AllorSites.*scope. - Run the device-code flow with your Application (client) ID. For writes,
replace
Files.ReadwithFiles.ReadWritein the request below:
Save the token for the examples
Get your drive ID (optional)
App-only tokens cannot use
/me/drive; set one of drive_id, site_id,
group_id, or user_id. Delegated tokens can use /me/drive directly.drive_id selector. With your token exported as
TOKEN:
b!a1B2c3....
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).