OptimiDoc Server Help Center

OneDrive Destination

The OneDrive destination uploads scanned documents to Microsoft OneDrive -- Personal or Business -- through the Microsoft Graph API. It uses interactive OAuth 2.0: register an Azure AD application, then authorise OptimiDoc from the destination's editor.


How It Works

OneDrive is a delivery-only destination built on Microsoft Graph. You register an Azure AD (Entra ID) application, enter its Client ID (and, for tenant-wide access, a Client Secret), then authorise OptimiDoc interactively. OptimiDoc stores the resulting tokens with the destination and refreshes them automatically. Documents are uploaded to the folder given in Path, which is honoured for both folder browsing and delivery.

Two variants are available:

  • OneDrive Personal -- for consumer Microsoft accounts.

  • OneDrive Business -- for OneDrive in a Microsoft 365 tenant, with an optional tenant-wide Admin Consent flow.


Configuration

OneDrive Personal

Setting

Description

Path

Target folder in OneDrive (e.g. /Documents/Scans).

Client ID

Application (client) ID of your Azure AD app.

Return URL

OAuth redirect URL -- your OptimiDoc server base URL (e.g. https://server.example.com/). Must match the app's registered redirect URI.

Overwrite Existing Files

Replace a file with the same name instead of keeping both.

OneDrive Business

Setting

Description

Path

Target folder in OneDrive.

Client ID

Application (client) ID of your Azure AD app.

Tenant ID

Directory (tenant) ID of your Microsoft 365 tenant.

Return URL

OAuth redirect URL (OptimiDoc server base URL).

Overwrite Existing Files

Replace same-named files.

Admin Consent

Authorise the app for the whole tenant via a Microsoft administrator instead of per-user authorisation.

Client Secret

(Admin Consent only) Client secret of the Azure AD app.

Import source

(Admin Consent only) The Azure AD directory -- configured in OptimiDoc's user-import settings -- that identifies the tenant.


Azure AD Application Setup

  1. In the Azure Portal, go to App registrations > New registration.

  2. Add your Return URL (the OptimiDoc server base URL) as a Redirect URI of type Mobile and desktop applications.

  3. Note the Application (client) ID and, for Business, also the Directory (tenant) ID.

  4. Under API permissions, add Microsoft Graph Files.ReadWrite (delegated).

  5. For Admin Consent, additionally create a Client Secret under Certificates & secrets and grant admin consent for the tenant.


Enable Admin Consent when a Microsoft administrator should authorise the application for the whole tenant, avoiding a per-user consent prompt at authorisation time. This mode requires a Client Secret and an Import source -- the Azure AD directory configured in OptimiDoc's user-import settings that identifies the tenant.


Authorising the Connection

  1. Enter the fields above and Save the destination.

  2. Re-open the destination. An OAuth Authorization card shows the current status (Not authorized or Authorized).

  3. Click Authorize. OptimiDoc redirects your browser to Microsoft's consent page; after you grant access you are returned to OptimiDoc and the tokens are stored with the destination.

  4. Once authorised, use Test Connection to confirm access. Test Connection is hidden until the destination is authorised.

Use Re-authorize to refresh access, or Revoke authorization to clear the stored tokens. Revoking removes only OptimiDoc's local copy of the tokens -- the remote provider is not contacted -- and preserves the configuration fields, so the destination returns to the Not authorized state until you authorise it again.


Troubleshooting

Issue

Possible Cause

Resolution

Authorisation fails with a token error

Wrong Client ID/Secret/Tenant, or redirect URI mismatch

Verify the credentials and that the Return URL exactly matches the app's redirect URI. OptimiDoc reports the token-exchange failure rather than failing silently.

Files land in the wrong folder

Path not set or misspelled

Set Path; it is honoured for both browsing and delivery.

Not authorized after previously working

Tokens revoked or expired without a refresh token

Re-open the destination and click Re-authorize.