FileRelay
Documentation
Try our Sandbox

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)

  1. Go to the Azure Portal → Microsoft Entra ID > App registrations → New registration (e.g. "FileRelay OneDrive").
  2. Note the Application (client) ID and Directory (tenant) ID from the Overview page.
  3. Go to Certificates & secrets → New client secret; copy the value immediately.
  1. Under API permissions → Add a permission > Microsoft Graph > Application permissions, add Files.ReadWrite.All.
  2. Click Grant admin consent (required — application permissions do not work without it).
  3. Find the target drive ID in Graph Explorer: GET https://graph.microsoft.com/v1.0/me/drives (or /users/{id}/drives for another user). Copy the drive's id (starts with b!).
  4. In FileRelay, add a OneDrive destination: Entra app-only mode, tenant + client + secret, and the drive ID.

Setup — delegated user (alternative)

  1. Under API permissions → Add a permission > Microsoft Graph > Delegated permissions, add Files.ReadWrite and offline_access.
  2. Create the client secret as above.
  3. Run the one-off authorization dance (replace the {…} values; the redirect URI must be registered under Authentication → Redirect URIs, e.g. https://localhost/blank for 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 code from 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_token from the JSON response.
  4. 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_id is required. Find it in Graph Explorer (GET /me/drives or /users/{id}/drives).
  • Delegated: uploads to the consenting user's drive by default; set drive_id to 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

FieldTypeRequiredDescription
folder_pathstringOptionalFolder path within OneDrive (e.g. SAP/Invoices)
drive_idstringOptionalDrive ID — required for app-only auth, optional for delegated (defaults to user drive)

Credentials

FieldTypeRequiredDescription
client_idstringRequiredEntra app (client) ID
client_secretstringRequiredEntra app client secret
tenant_idstringRequiredEntra tenant ID
refresh_tokenstringOptionalDelegated-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.

Get Started Free