Google Drive is a file storage and synchronization service developed by Google. It allows users to store, synchronize and share files. Google Drive is a key component of Google Workspace, Google's monthly subscription offering for businesses.

You can use Frappe Framework's file picker to select any file from Google Drive and attach it to the current DocType. For example, you can attach the invoice PDF stored in Google Drive to a Purchase Invoice in your Frappe app.

Setup

Google Cloud Console

First we need to get some credentials that will allow us to access Google Drive. You can use the setup tool, which guides you through creating a project in the Google Cloud Console, enabling the API, and creating credentials.

If you haven't done so already, create your application's API key by clicking Create credentials > API key. Next, look for your API key in the API keys section. You can open the API Key and restrict it.

  1. Under Application restrictions choose "HTTP referrers",

  2. under Website restrictions add your frappe instance's hostname and

  3. under API restrictions choose "Restrict key" and select the "Google Picker API".

API Key configuration

If you haven't done so already, create your OAuth 2.0 credentials by clicking Create credentials > OAuth client ID.

  1. Under Application type choose "Web application" and

  2. under Authorized JavaScript origins add your frappe instance's hostname.

OAuth Client configuration

After you've created the credentials, you can see your client ID on the Credentials page.

Last but not least you need to configure the OAuth Consent Screen. This is the page that users will see when they are using the Google Drive Picker for the first time. It asks them to grant access to their Google Drive. You can configure this as you like, just take care to add the scope https://www.googleapis.com/auth/drive.readonly on the Scopes page.

You will also need your App ID at hand. This is your project number which you can find under IAM & Admin > Settings.

Portions of this section are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 4.0 Attribution License.

Frappe instance

Now that the Google Picker API is enabled and we have the necessary credentials we can go ahead and configure the Google Settings in you Frappe instance.

  1. Open Google Settings.

  2. Check the Enable checkbox.

  3. In the "Google Drive Picker" section, check the Google Drive Picker Enabled checkbox.

  4. Enter your App ID, Client ID and API Key.

  5. Save the Google Settings and reload your browser window.

Google Settings

Now when you click on "Attach file" in the sidebar, you should see the Google Drive icon.

Attach File Dialog

If you click on it for the first time, you have to authorize the Frappe app to access your Google Drive files.

Google Sign In

Then the Google Drive Picker opens and you can choose a file.

Google Drive Picker

Click the blue button on the bottom left to attach a link to this file to the current DocType.

File Attached to DocType

In case you're looking for technical details, Google Drive was introduced in Pull Request #12715.