Skip to main content

Required Scopes

To configure a Sync for Google Drive, you need to request the following scopes from your Google OAuth application:
  • https://www.googleapis.com/auth/drive.readonly
    If you are syncing only user-selected files, you can request the less permissive https://www.googleapis.com/auth/drive.file scope.This will restrict the sync to only files that the user has selected with the Google Drive File Picker.
  • https://www.googleapis.com/auth/admin.reports.audit.readonly (optional - for including link-sharing access in the Permissions Sync)
Learn more about configuring scopes for your app in Adding Integrations.

Synced Objects

Google Drive supports the following Synced Objects:
  • Files

    Google Docs, Sheets, and Slides will be synced as their Office-compatible equivalent formats:

    • Docs: DOCX file
    • Sheets: XLSX file
    • Slides: PPTX file
    • Drawings: PDF file
  • Permissions

Files

Send a request to Enable Sync to start a file sync. Syncs for Google Drive can be created with one of the following configurations:
  • Global Sync: All files in the user’s Google Drive account will be synced.
  • Folder Sync: Only files in the specified folder will be synced (recursively including all subfolders).
  • Sync of specific files: Only a group of specific files will be synced.
  • Global Sync
  • Folder Sync
  • Sync of specific files
Example
{
    "integration": "googledrive",
    "pipeline": "files",
    "configuration": {}
}
Configuration options:No configuration options are required for a global Sync.

Choosing Files and Folders

You can allow your user to select files from their Google Drive account in your app with the Google Drive File Picker provided by the Paragon SDK.
Enable the Google Picker API You will need to enable the Google Picker API for your application in order to access the File Picker.
  1. In your Google Cloud Console dashboard, navigate to APIs & Services > Library in the sidebar for your app.
  2. Search for “Google Picker API” from the API Library.
  3. Select the “Google Picker API” and press the blue “Enable” button to enable the API for your application.
Creating a Google Drive API Key To show the Google Drive File Picker, you will need a Google Drive API Key. This key is a separate key from the Client ID you provided to Paragon during integration setup.
  1. Navigate to Google Cloud Console > APIs & Services > Credentials. Make sure the selected project in the header is your app.
  2. Click Create Credentials and select API key.
  3. An API key value will appear. Copy this value to use in Showing the File Picker.
Note: While the API Key value is not sensitive and can safely be used in your public application, we recommend restricting the API Key with the following settings:
  • Application restrictions: Websites with your origin/domain
  • API restrictions: Google Drive API
Read more in Google’s docs for API Key restrictions.

Showing the File Picker

Use the Paragon SDK in your frontend application to show the File Picker in your app. The SDK provides an ExternalFilePicker class to load Google’s JavaScript into your page and authenticate with your user’s connected Google Drive account. To initialize the picker you will need your Google Drive API key and your Google Cloud project number. The Google Cloud project number is a unique, numerical identifier for your project. You can find it within the Google Cloud Console from the sidebar navigation under IAM & Admin section > Settings.
let picker = new paragon.ExternalFilePicker("googledrive", {
    onFileSelect: (files) => {
        // Handle file selection
    }
});

// Loads external dependencies and user's access token
await picker.init({ developerKey: "YOUR_GOOGLE_API_KEY", "appId": "YOUR_GOOGLE_PROJECT_NUMBER" });

// Open the File Picker
picker.open();
You can configure the File Picker to listen for additional callbacks or to restrict allowed file types. Learn more about configuring File Picker options in the SDK Reference.
I