Skip to main content

Widget GoogleDocsPicker (Drive Picker)

The GoogleDocsPicker widget allows users to select and import documents from Google Drive directly into your application. It provides a seamless integration with Google Drive API, enabling users to browse, select, and upload files from their Google Drive account.

OverviewDirect link to Overview

This widget creates a button that, when clicked, opens the Google Drive Picker interface. Users can browse through their files, shared files, and recently accessed documents. Selected files are automatically downloaded and uploaded to your platform's file system.

Drive Picker Widget

Basic ConfigurationDirect link to Basic Configuration

  • Name: Display name for the widget

  • Variable/Model: The variable name that will store the selected files array

  • Button Type: Visual style of the button

    • primary (blue)
    • success (green)
    • info (gray)
    • warning (orange)
    • danger (red)
  • Button Size: Size of the button

    • medium
    • small
    • mini
  • Button Alignment: Horizontal alignment

    • left
    • center
    • right
  • Icons: Optional prefix and suffix icons to enhance the button appearance

    • Prefix Icon: Icon displayed before the button text
    • Suffixe Icon: Icon displayed after the button text
Drive Picker Basic Configuration

Credentials ConfigurationDirect link to Credentials Configuration

The widget requires Google credentials to function properly. They are stored in Volt, then selected in the Credentials section of the widget.

Required CredentialsDirect link to Required Credentials

  • Client ID: OAuth 2.0 client ID from Google Cloud Console
  • API Key: Google API key from Google Cloud Console, restricted by HTTP referrer to your domain

Since version 8.6, the Client Secret is no longer needed: the picker runs in the browser with the API key and the client ID only, and the page no longer receives the OAuth client secret. The Client Secret field is still in the panel but is ignored: leave it empty. Existing widgets keep working without any change.

These values are printed in the page

The Volt values selected in this widget are printed in the page: anyone who can open the page can read them in its source. Only select keys meant for the browser, that is the client ID and an API key restricted by HTTP referrer, and never a secret. This widget is an exception to the rule that a page does not read Volt values.

Drive Picker Required Credentials

Setting Up CredentialsDirect link to Setting Up Credentials

  1. Go to Google Cloud Console
  2. Create a new project or select an existing one
  3. Enable the Google Drive API and Google Picker API
  4. Create an OAuth 2.0 client ID and an API key, and restrict the API key by HTTP referrer to the domain of your pages
  5. Create 2 variables with New variable, in Settings › Volt (/ide/settings/volt) or in the Design mode of the project › Volt, with the Text value type and one value per environment (the page reads the value of the environment it runs in):
    • google_drive_client_id
    • google_drive_api_key
New Volt variable for the Google API key
  1. Select the variables in the Credentials section of the widget:
    • Client Id: google_drive_client_id
    • Api Key: google_drive_api_key
    • Client Secret: leave it empty, it is ignored

FeaturesDirect link to Features

File Selection InterfaceDirect link to File Selection Interface

The widget opens Google Drive Picker with multiple views:

  • My Drive: Files owned by the user
  • Shared with me: Files shared by others
  • Shared drives: Team drive files
  • Recent: Recently accessed files

Supported File TypesDirect link to Supported File Types

The widget handles two categories of files:

  1. Native Google Files: Documents, Spreadsheets, Presentations
    • Automatically exported to standard formats (PDF for docs, CSV for sheets)
  2. Regular Files: All other file types
    • Downloaded in their original format

Validation OptionsDirect link to Validation Options

Screen-based ValidationDirect link to Screen-based Validation

Configure different states for different screens/contexts:

  • Available: Whether the widget is available on the screen
  • Visible: Whether the widget is visible to users
  • Required: No effect on this widget, see below
  • Disable: Whether the widget is disabled
Required and Rules have no effect on this widget

The panel shows the Required column and the Rules section, but this button is not a form field: the page never checks them. With Required on, a validateForm action lets an empty picker through and no message appears. To require a file, test the variable of the widget: see Making a Selection Mandatory.

Drive Picker Screen-based Validation

Advanced ConditionsDirect link to Advanced Conditions

Use dynamic conditions with variables: click Advanced Setting in the Validation section, then the pencil of the rule. In this example, the picker is only visible when document_source is drive:

Drive Picker Advanced Conditions

Validation RulesDirect link to Validation Rules

The Rules section of the panel has no effect on this widget: its rules are never applied and their messages never appear. See Making a Selection Mandatory.

Styling OptionsDirect link to Styling Options

  • CSS Classes: Add custom CSS classes for styling
  • Dynamic Classes: Use conditions to apply classes based on data state
Drive Picker Styling Options

Usage ExamplesDirect link to Usage Examples

Making a Selection MandatoryDirect link to Making a Selection Mandatory

Required blocks nothing on this widget, so test its variable on the button that goes on. Select this button, open its Validation section, click Advanced Setting, then the pencil of Disable, and write a condition on the variable of the picker, here drive_files:

!{{drive_files}} || {{drive_files}}.length == 0

The button stays disabled until a file is selected. You can also put this condition in an if action, first in the actions of the button, to show a message instead.

Disable condition of the button that goes on

Advanced ConfigurationDirect link to Advanced Configuration

The picker is only shown for an active project, with the Visible condition {{project_status}} == 'active':

Drive Picker Advanced Configuration

Security ConsiderationsDirect link to Security Considerations

  • Ensure proper OAuth scope configuration
  • Only select browser keys in this widget (client ID, API key restricted by HTTP referrer): the Volt values it reads are printed in the page
  • The OAuth client secret is not used: do not select it in this widget
  • Implement proper access controls for file uploads
  • Validate file types and sizes on the server side

TroubleshootingDirect link to Troubleshooting

Common IssuesDirect link to Common Issues

  1. Authentication Errors: Verify credentials are correctly configured
  2. Picker Not Opening: Check if Google APIs are enabled
  3. File Upload Failures: Verify server-side file handling
  4. CORS Issues: Ensure proper domain configuration in Google Console

Debug TipsDirect link to Debug Tips

  • Check browser console for API errors
  • Verify OAuth redirect URIs match your domain
  • Test with different file types and sizes
  • Monitor network requests for API call failures

Browser SupportDirect link to Browser Support

The widget requires modern browsers with support for:

  • ES6 JavaScript features
  • OAuth 2.0 authentication
  • File API for upload handling
  • Modern CSS features for styling