OneDrive
Forward SAP documents to OneDrive personal or business drives. Supports folder paths, specific drive targeting, and automatic folder creation.
Use Cases
- Microsoft 365 document archive
- Personal library storage for SAP documents
- OneDrive for Business team file distribution
Forward SAP documents to Microsoft OneDrive via the Graph API, with automatic folder creation.
Choose authentication
| Option | When to use |
|---|---|
| Entra app-only (recommended) | Unattended archiving. No user session, no token dance — needs the drive ID and an admin-consented app permission. |
| Delegated user (alternative) | A specific user's drive without admin consent on Files. Requires a one-off browser dance to obtain a refresh token. |
Setup — app registration (both modes)
- Go to the Azure Portal → Microsoft Entra ID > App registrations → New registration (e.g. "FileRelay OneDrive").
- Note the Application (client) ID and Directory (tenant) ID from the Overview page.
- Go to Certificates & secrets → New client secret; copy the value immediately.
Setup — app-only (recommended)
- Under API permissions → Add a permission > Microsoft Graph > Application permissions, add
Files.ReadWrite.All. - Click Grant admin consent (required — application permissions do not work without it).
- Find the target drive ID in Graph Explorer:
GET https://graph.microsoft.com/v1.0/me/drives(or/users/{id}/drivesfor another user). Copy the drive'sid(starts withb!). - In FileRelay, add a OneDrive destination: Entra app-only mode, tenant + client + secret, and the drive ID.
Setup — delegated user (alternative)
- Under API permissions → Add a permission > Microsoft Graph > Delegated permissions, add
Files.ReadWriteandoffline_access. - Create the client secret as above.
- Run the one-off authorization dance (replace the
{…}values; the redirect URI must be registered under Authentication → Redirect URIs, e.g.https://localhost/blankfor a manual copy-paste):- Open in a browser and sign in as the drive owner:
https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/authorize?client_id={client_id}&response_type=code&scope=Files.ReadWrite%20offline_access&redirect_uri={redirect_uri} - Copy the
codefrom the redirected URL and exchange it:curl -X POST "https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token" \ -d "client_id={client_id}&client_secret={client_secret}&grant_type=authorization_code" \ -d "code={code}&redirect_uri={redirect_uri}&scope=Files.ReadWrite%20offline_access" - Copy the
refresh_tokenfrom the JSON response.
- Open in a browser and sign in as the drive owner:
- In FileRelay, add a OneDrive destination: delegated mode with tenant + client + secret + refresh token. Drive ID is optional (defaults to that user's drive).
REPLACE: Screenshot of the OneDrive connector configuration form in FileRelay
Test
Click Test — FileRelay uploads a probe file to the folder path and deletes it, proving the app (or user grant) can write. A passing test is required before saving.
How It Works
App-only mints a short-lived token per send (cached until just before expiry) and uploads to /drives/{id}. Delegated mode exchanges the refresh token per send and uploads to /me/drive (or the given drive). Folders are created automatically; files over 4MB use chunked upload sessions.
Folder Structure
Documents are uploaded to:
{folder_path}/{subfolder}/{doc_id}.{ext}
- folder_path — the configured path (e.g.
SAP/Invoices), or root if omitted - subfolder — automatic subfolder based on routing rules (date, repository, or none)
- doc_id — the SAP document ID
- ext — file extension based on MIME type
Folders are created automatically if they do not exist. FileRelay creates each level of the path as needed.
Drive Targeting
- App-only:
drive_idis required. Find it in Graph Explorer (GET /me/drivesor/users/{id}/drives). - Delegated: uploads to the consenting user's drive by default; set
drive_idto target a shared or specific drive. - SharePoint libraries — use the dedicated SharePoint connector instead, which resolves sites and libraries by name.
Permissions
| Permission | Type | Purpose |
|---|---|---|
Files.ReadWrite.All |
Application | App-only access to drives (recommended) |
Files.ReadWrite |
Delegated | The consenting user's files |
offline_access |
Delegated | Keeps the refresh token alive for background use |
Enriched metadata
Without a drive_id-addressable drive (delegated /me), metadata is skipped. With a drive ID, enrichment key-values are written to the item's list fields through the optional metadata_mapping (our key → column); unmapped keys pass through as column names.
Troubleshooting
| Symptom | Cause / fix |
|---|---|
| 401/403 on Test, app-only | Admin consent missing, or Files.ReadWrite.All not granted — consent is mandatory for app permissions. |
| 403 on a specific folder | The app (or user) lacks write on that folder; check sharing settings. |
| Delegated stops working after idle months | Refresh token expired from disuse — run the dance again for a fresh token. |
drive_id rejected in app-only |
Drive ID copied wrong — it starts with b! and belongs to the same tenant. |
Configuration Fields
| Field | Type | Required | Description |
|---|---|---|---|
| folder_path | string | Optional | Folder path within OneDrive (e.g. SAP/Invoices) |
| drive_id | string | Optional | Drive ID — required for app-only auth, optional for delegated (defaults to user drive) |
Credentials
| Field | Type | Required | Description |
|---|---|---|---|
| client_id | string | Required | Entra app (client) ID |
| client_secret | string | Required | Entra app client secret |
| tenant_id | string | Required | Entra tenant ID |
| refresh_token | string | Optional | Delegated-mode refresh token (omit for app-only auth) |
All credentials are encrypted at rest using envelope encryption.
Ready to set up OneDrive?
Create a free account and add this connector in under 2 minutes.