Skip to content
AsterDrive
Security update: Docker images from v0.4.0-rc.1 fix the high-severity FFmpeg MagicYUV decoder vulnerability (CVE-2026-8461). Upgrade instances using older images immediately.View CVE advisory
Security update: v0.4.0-beta.3 fixes a WebDAV request issue that can terminate the server process. Upgrade older instances promptly.View advisory

OneDrive Storage Policy Tutorial

OneDrive storage policies are suitable when:

  • You already use Microsoft 365, OneDrive, or SharePoint document libraries
  • You want team files to be stored in a Microsoft Graph-accessible drive
  • You want an administrator to authorize one OneDrive / SharePoint drive as an AsterDrive backend
  • You want to use Microsoft Graph delegated permissions through browser-based administrator authorization

If you only need a generic object-storage backend, S3 / MinIO / R2 or Tencent COS is usually more direct. OneDrive integrates with the Microsoft ecosystem, but it requires correct Microsoft app registration, OAuth redirect URI, and delegated permissions.

Microsoft app registration

AsterDrive OneDrive storage policy

Microsoft Graph OAuth authorization

Target drive / root item

Policy group rule

User or team bound to the policy group

Microsoft app registration

AsterDrive OneDrive storage policy

Microsoft Graph OAuth authorization

Target drive / root item

Policy group rule

User or team bound to the policy group

Creating only a OneDrive storage policy is not enough. After saving the policy and Microsoft Graph application credentials, authorize Microsoft from the AsterDrive admin console so AsterDrive can obtain delegated tokens for the target drive.

What you want to doEntry
Create a OneDrive policyAdmin -> Storage Policies -> New Policy
Copy the Microsoft redirect URIAdmin -> Storage Policies -> OneDrive policy -> Microsoft Graph credential
Authorize or reauthorizeAdmin -> Storage Policies -> OneDrive policy -> Authorize
Validate the saved credentialAdmin -> Storage Policies -> OneDrive policy -> Validate
Create routing rulesAdmin -> Policy Groups
Bind a policy group to a userAdmin -> Users -> User Details
Bind a policy group to a teamAdmin -> Teams -> Team Details

Choose the Microsoft cloud endpoint when creating the OneDrive policy:

CloudSign-in endpointGraph endpointAccounts
Globallogin.microsoftonline.comgraph.microsoft.comPersonal Microsoft accounts and Entra ID work or school accounts
China (21Vianet)login.chinacloudapi.cnmicrosoftgraph.chinacloudapi.cnChina cloud organization accounts

Prepare an app in Microsoft Entra ID app registrations.

At minimum, check:

  • Application (client) ID
  • Client Secret, required by the current AsterDrive server-side storage authorization flow
  • Redirect URI
  • Microsoft Graph delegated permissions

AsterDrive shows the redirect URI on the OneDrive policy edit page. Copy that full URI into the Microsoft app registration.

A common form is:

https://drive.example.com/api/v1/admin/policies/storage-authorization/callback

Microsoft matches redirect URIs exactly. If the scheme, host, port, or path differs by even one character, the authorization callback fails.

OneDrive storage policies use Microsoft Graph delegated authorization completed by an administrator in the browser. They do not use application permissions.

AsterDrive chooses default authorization scopes by target type:

Target typeDefault scopes
Personal OneDrive / default work or school OneDriveoffline_access Files.ReadWrite
Personal or work/school account with explicit Drive IDoffline_access Files.ReadWrite.All
SharePoint site drive / Microsoft 365 group driveoffline_access Files.ReadWrite.All Sites.ReadWrite.All

Do not manually enter scopes in the AsterDrive frontend. Make sure the Microsoft app registration allows the required delegated permissions, then grant consent on the Microsoft authorization page.

Open:

Admin -> Storage Policies -> New Policy

Choose the driver type:

OneDrive

Fill in:

FieldRecommendation
Microsoft cloudChoose Global or China based on the account’s cloud
Client IDApplication (client) ID from the Microsoft app registration
Client SecretMicrosoft app secret; currently required. Public-client / no-secret flows are not supported by this storage backend.
Drive typeUsually keep the default during creation and let authorization resolve the default drive
OneDrive upload modeChoose Server relay or Microsoft Graph direct upload based on bandwidth flow; Graph direct upload needs no additional cross-origin configuration
OneDrive download modeChoose Server relay or Microsoft Graph direct download based on bandwidth flow

After saving the policy, open the policy edit page and start authorization.

Open the OneDrive policy edit page:

Admin -> Storage Policies -> target OneDrive policy

In the Microsoft Graph credential panel, click Authorize.

Authorization uses the saved Microsoft application settings and does not read an unsaved Client ID or Client Secret from the page. After authorization succeeds, the browser returns to the AsterDrive admin console and shows the result.

AsterDrive securely stores the information needed for later OneDrive access and renews authorization when needed. If Microsoft revokes access or the credential expires, the policy page prompts the administrator to authorize again.

Usually you do not need to enter a Drive ID. AsterDrive resolves it after authorization:

Drive typeResolution
Personal OneDriveThe signed-in account’s default drive
Work or school OneDriveThe signed-in account’s default drive
SharePoint site driveThe site’s default drive by Site ID, unless Drive ID is provided
Microsoft 365 group driveThe group drive by Group ID, unless Drive ID is provided

Use advanced fields only when you need a non-default document library or a fixed root item:

FieldWhen to use it
Drive IDTarget a non-default drive or bypass automatic resolution
Root item IDRestrict AsterDrive writes to a specific folder
Site IDRequired for SharePoint site drive mode unless Drive ID is provided
Group IDRequired for Microsoft 365 group drive mode unless Drive ID is provided

OneDrive policies support two upload modes:

Upload modeData pathBest fit
Server relay (server_relay)Browser -> AsterDrive -> Microsoft GraphThe default retained for compatibility with existing policies; browser traffic always passes through AsterDrive
Microsoft Graph direct upload (frontend_direct)Browser uploads directly to Microsoft GraphAn out-of-the-box bandwidth-saving path for large files or servers with limited bandwidth

Server relay is the default to preserve existing policy behavior. Administrators can switch the upload mode on the OneDrive policy edit page.

The browser uploads the file to AsterDrive first, then the server writes it to Microsoft Graph.

This path consumes upload bandwidth on the AsterDrive node, but browsers only need connectivity to AsterDrive. Prefer it when user devices cannot connect reliably to Microsoft.

AsterDrive confirms the upload, then the browser sends the file directly to Microsoft Graph. The file does not pass through the AsterDrive node, which can substantially reduce server bandwidth use.

Server relay

Microsoft Graph direct upload

Browser selects a file

OneDrive upload mode

File passes through AsterDrive

Microsoft Graph

File bypasses AsterDrive

AsterDrive shows upload complete

Server relay

Microsoft Graph direct upload

Browser selects a file

OneDrive upload mode

File passes through AsterDrive

Microsoft Graph

File bypasses AsterDrive

AsterDrive shows upload complete

Microsoft access and refresh tokens always stay on the AsterDrive server and are never sent to the browser. Interrupted direct uploads can continue, while canceled or expired uploads are cleaned up automatically.

The download mode is configured separately:

Download modeBest fit
Server relayCompatibility first; the file passes through AsterDrive before reaching the browser
Microsoft Graph direct downloadReduces AsterDrive download bandwidth; the browser fetches the file directly from Microsoft

When Microsoft Graph direct download is enabled, you can also choose the download filename:

Download filenameBehavior
Prefer the OneDrive filenameRenamed files still prefer direct download; the downloaded name may remain the name stored in OneDrive
Always use the AsterDrive filenameUse relay streaming when the names differ, so the download uses AsterDrive’s current filename

With direct download, AsterDrive still checks the signed-in user, permissions, sharing rules, and download rules first. It then sends the browser to a short-lived Microsoft download URL. Microsoft transfers the file, so the AsterDrive node does not relay the complete file body.

New files uploaded to OneDrive keep their original filenames. Files with the same name are stored in separate locations and do not overwrite one another. The policy also offers a download filename choice: by default it prefers the filename stored in OneDrive so renamed files can keep using direct download; strict AsterDrive filenames use relay streaming when the names differ.

Direct download needs no additional Microsoft or AsterDrive cross-origin setting. If the browser or company network cannot reach Microsoft, the download falls back to server relay; administrators can also select server relay directly in the policy editor.

Do not move real users to a new OneDrive policy immediately. Create a test policy group first.

Open:

Admin -> Policy Groups

Create a policy group, for example:

OneDrive Test Group

Add one rule:

FieldRecommendation
Storage policyThe OneDrive policy you just created and authorized
PriorityKeep the default or make it match first
File size rangeCover all sizes first, which makes testing easier

Open:

Admin -> Users -> User Details

Change the test user’s policy group to OneDrive Test Group.

Open:

Admin -> Teams -> Team Details

Change the test team’s policy group to OneDrive Test Group.

Team space uploads follow the team policy group, not the individual user’s policy group.

With a test account, run at least:

  1. Upload a small and a larger file with server relay
  2. Switch to Graph direct upload and repeat both uploads
  3. Download a file once with server relay and once with Microsoft Graph direct download
  4. Upload two files with the same name and confirm that both open and download correctly
  5. Rename one of them, then download it. In provider_native mode, the download may retain the older filename stored by OneDrive; switch to strict_current before asserting that the download uses AsterDrive’s current filename.
  6. Preview an image or trigger thumbnail generation
  7. Delete and restore a file
  8. Confirm on the Microsoft side that objects are written into the target drive
  9. Click Validate in the AsterDrive admin console

If the admin console reports that Microsoft Graph authorization has expired, check the credential status on the policy edit page. If the status requires reauthorization, click Reauthorize.

AsterDrive encrypts the Microsoft Client Secret and authorization information. Plaintext credentials are not returned to the browser, API responses, or audit logs.

When editing an existing policy, leave Client Secret empty to keep the saved secret. Enter and save a new value only when replacing it.

Credential encryption depends on auth.storage_credential_secret_key. Preserve this setting when backing up or migrating AsterDrive. See Authentication & Session - storage_credential_secret_key.

Check in this order:

  1. Whether the redirect URI matches exactly
  2. Whether Client ID / Secret come from the same Microsoft app
  3. Whether the Microsoft cloud endpoint is correct
  4. Whether a personal Microsoft account was accidentally used with the China endpoint
  5. Whether the Microsoft app allows the required delegated permissions

Authorization Succeeds but Drive Resolution Fails

Section titled “Authorization Succeeds but Drive Resolution Fails”

Check the Drive type and target fields:

  • Default personal / work-school OneDrive usually does not need Drive ID
  • SharePoint site drive needs Site ID unless Drive ID is provided
  • Microsoft 365 group drive needs Group ID unless Drive ID is provided
  • Leaving Root item ID empty or root is the safest initial setup

The refresh token is usually unavailable or rejected by Microsoft. Check:

  • Whether authorization included offline_access
  • Whether Microsoft organization policy restricts refresh tokens
  • Whether an administrator revoked the grant on the Microsoft side
  • Whether Client Secret was rotated but the AsterDrive policy was not updated

Server Relay Works but Microsoft Graph Direct Upload Fails

Section titled “Server Relay Works but Microsoft Graph Direct Upload Fails”

First confirm that regular upload, download, and the admin Validate action work. Then check browser extensions, the company network, and whether the correct Microsoft cloud is selected. AsterDrive has no additional Graph cross-origin setting. This type of problem usually affects only browser-direct upload; switch back to server relay when needed.

Microsoft Graph Direct Download Is Not Used

Section titled “Microsoft Graph Direct Download Is Not Used”

First confirm that the OneDrive policy selects Microsoft Graph direct download. With Always use the AsterDrive filename, renamed files use relay streaming; older objects or browsers that cannot reach Microsoft may also use relay streaming.