---
title: Google Drive
description: Forward SAP documents to Google Drive folders. Supports shared drives, automatic subfolder creation, and OAuth-based access.
type: google_drive
use_cases:
  - Share invoices with non-SAP users
  - Collaborative document review in Google Workspace
  - Mobile access to SAP documents
config_fields:
  - name: folder_id
    type: string
    required: false
    desc: "Google Drive folder ID (default: root)"
credential_fields:
  - name: client_id
    type: string
    required: true
    desc: "Google OAuth 2.0 Client ID"
  - name: client_secret
    type: string
    required: true
    desc: "Google OAuth 2.0 Client Secret"
  - name: refresh_token
    type: string
    required: true
    desc: "OAuth 2.0 refresh token"
---

Forward SAP documents to Google Drive. FileRelay uses the Google Drive API to upload files, create subfolders automatically, and supports both personal drives and shared (team) drives.

## Setup

1. Go to the [Google Cloud Console](https://console.cloud.google.com/) and create a new project (or select an existing one)
2. Navigate to **APIs & Services > Library** and enable the **Google Drive API**
3. Go to **APIs & Services > OAuth consent screen**, configure the consent screen, and add the scope `https://www.googleapis.com/auth/drive.file`
4. Go to **APIs & Services > Credentials** and click **Create Credentials > OAuth 2.0 Client ID**
5. Set the application type to **Web application**
6. Add `https://developers.google.com/oauthplayground` as an authorized redirect URI
7. Copy the **Client ID** and **Client Secret**
8. Open the [OAuth 2.0 Playground](https://developers.google.com/oauthplayground), click the gear icon, check **Use your own OAuth credentials**, and enter your Client ID and Client Secret
9. In Step 1, select **Google Drive API v3** and authorize the scope `https://www.googleapis.com/auth/drive.file`
10. In Step 2, click **Exchange authorization code for tokens** and copy the **Refresh Token**
11. In FileRelay, add a **Google Drive** destination with the Client ID, Client Secret, Refresh Token, and optionally a folder ID

> **REPLACE:** Screenshot of the Google Drive connector configuration form in FileRelay

## How It Works

FileRelay authenticates with Google using the OAuth 2.0 refresh token to obtain a short-lived access token. Documents are uploaded to the specified folder via the Google Drive API v3. If no folder ID is provided, files are uploaded to the root of the authenticated user's drive.

For files larger than 5MB, FileRelay automatically uses resumable uploads to handle large documents reliably over unstable network connections.

## Folder Resolution

The **folder_id** is the alphanumeric string at the end of a Google Drive folder URL:

```
https://drive.google.com/drive/folders/1aBcDeFgHiJkLmNoPqRsTuVwXyZ
                                        └─────── folder_id ───────┘
```

To use a **Shared Drive** (formerly Team Drive), copy the folder ID from within the shared drive. FileRelay detects shared drives automatically and sets the `supportsAllDrives` flag on API calls.

If the `folder_id` field is left empty, documents are placed in the root of the authenticated user's **My Drive**.

## Path Structure

Documents are uploaded with the following structure:

```
{folder}/{subfolder}/{doc_id}.{ext}
```

- **folder** — the configured Google Drive folder (or root if omitted)
- **subfolder** — automatic subfolder based on your routing rules (date-based, repository name, or flat); created if it does not exist
- **doc_id** — the SAP document ID
- **ext** — file extension based on MIME type

Subfolders are created as nested Google Drive folders. FileRelay checks for an existing folder with the same name before creating a new one to avoid duplicates.

## Required OAuth Scopes

| Scope | Purpose |
|-------|---------|
| `drive.file` | Create and manage files that FileRelay uploads |

> If you need FileRelay to write into existing folders that were not created by the app, use the broader `drive` scope instead. The `drive.file` scope is recommended for least-privilege access.

## Tips

- **Shared Drives** — The authenticated user must be a member of the Shared Drive with at least **Contributor** access. If uploads fail with a permissions error, verify membership in the Google Admin Console.
- **Folder not found** — Double-check that the folder ID is correct and that the authenticated user has write access. Folder IDs are case-sensitive.
- **Token expiry** — Refresh tokens do not expire unless the user explicitly revokes access or the Google Cloud project's OAuth consent screen is in **Testing** mode with the token older than 7 days. Set your consent screen to **Production** to avoid this.
- **Google Workspace restrictions** — If your organization enforces domain-wide app restrictions, an admin may need to approve the OAuth client in the **Google Admin Console > Security > API controls**.
- **File naming** — FileRelay names uploaded files using the SAP document ID and original file extension. Duplicate names in the same folder result in separate files (Google Drive allows files with identical names).
- **Quota** — Google Drive API has a default quota of 12,000 requests per minute per project. For very high-volume SAP environments, request a quota increase in the Cloud Console.
