Integrating Salesforce with Google Drive in 3 easy steps

Sombir Sheoran
6 min readAug 9, 2022

--

Accessing Google Drive files… Step by step. 🚀

Integrating Salesforce with Google Drive

Those 3 easy steps are ⚙️:

  • Making Google Drive ready for Integration
  • Making Salesforce ready for Integration
  • & finally, let’s connect the dots…

Making Google Drive Ready for Integration

Creating a Project in the Google Developers Console

  1. First, you need an existing Google account. If not sign up here.
  2. Then login with Google credentials to your Google App for Work admin account: https://console.cloud.google.com/
Create a New Project

3. Create New Project, give it a name let's say Salesforce Integration, Save it and finally Select the newly created project.

New Project created
New Project created and selected as Active

4. From the project dashboard, click the Menu icon in the upper left, and then click APIs and Services. Then, Enable APIs and Services, and search for Google Drive API. Select it and click Enable API on Google Drive API

a: Enable API Dashboard
b: Search for Google Drive API
c: Enable ‘Google Drive API’

Preparing for Google Drive Credentials

  1. Now, click Credentials in the menu on the left side.
  2. In the OAuth Consent Screen tab, enter a valid email address and application name, and click Save. Make sure to Publish the app, so that publication status becomes In production for the record.
OAuth Consent Screen

3. In the Credentials tab, click on Create Credentials, select OAuth Client Id

click on Create Credentials, select OAuth Client Id

4. Select Application type as a Web application, give it a name, e.g. SalesforceGoogleDriveClient and Create.

5. Copy the client Id and client secret which gets created in the above step and save it in a text file. Optionally, you can download and save the JSON file which gets created for later usage.

Imporatant:

The client Id and client secret created in the above step would be used in the upcoming step which creates an auth. provider in Salesforce for Google drive.

Making Salesforce Ready for Integration 👀

Creating an Auth. Provider in Salesforce

  1. From Setup > search for Auth. Providers in the Quick Find box and then select Auth. Providers. Click New to create a fresh record.
  2. For Provider Type, select Open ID Connect
Provider Type: Open ID Connect

3. Now, for the new Auth. Providers fill in the below details as mentioned:

Once all details are entered, Save the record. It should look something like the below:

New Auth Provider details.

4. Note down the Callback URL value from the newly created record. This URL value would be used while editing the Google project created in the earlier steps.

https://sombirsheoran-dev-ed.my.salesforce.com/services/authcallback/GoogleDriveProvider

Call back URL

Editing Google Drive Project with Callback URL

  1. Go again to our Google Drive API Manager page, in the left side of the menu, click Credentials
  2. Click to open the previously created web app: SalesforceGoogleDriveClient
  3. In the Authorised redirect URIs section of the page, click Add URI to add the Callback URL while creating the Auth. Providers in Salesforce:
Modifying the Google Drive web app for Authorised redirect URIs

4. Enter Authorised redirect URIs = Callback URL value and save it.

Enter Authorised redirect URIs with the callback URL value

Now the initial setup is ready from the Google Drive and Salesforce perspectives.

& Finally, Let’s connect the dots…

Define an External Data Source for Google Drive

  1. From Setup > search for External Data Sources: Select ‘External Data Sources’ and create a new record.
  2. Give it a meaningful name and select Files Connect: Google Drive for the Type field.
  3. For Identity Type, select Per user and OAuth 2.0 for the Authentication protocol.
  4. For the Authentication Provider, select the GoogleDriveProvider record created in earlier steps.
  5. Leave Scope as Blank.
  6. Select Start Authentication Flow on Save as True to immediately test the settings above. The final result should look as below:
New External Data Source

7. On Save, it will launch Google authenticator to select your Google account to proceed.

Important:

You might get errors like below in case your web app in not published

Google authorization error

8. Click Go to salesforce.com (unsafe) to verify the app and proceed

Verify Google app

9. In the next step, select all required permissions, as mentioned in the scope, and click continue.

10. Finally, you’re routed back to External Data Source: Google Drive. It should show status as Authorized. Click on Validate and Sync, select Sync in the background, and wait until Status moves from RUNNING to COMPLETE. It creates a new External object: items_Google_Drive

The New External Data source is ready

10. Create a new permission set FilesConnect Permission Set as mentioned in the blog and make sure the following permissions are added and assigned to required users.

Files Connect Cloud: Access cloud-based external content sources, such as SharePoint Online: This is a system permission

Now we need to add newly created Custom Object (External) and External Data Source to the already created permission set: FilesConnect Permission Set : items_Google_Drive

11. Optionally, you can create a new tab with the new object items_Google_Drive so that can be launched to verify the data.

Verifying success: 🧪Test Google Drive connection

  1. In Salesforce lightning, go to the Files tab and make sure you’ve Google Drive as a connected source to access its files. Select any random file to perform a valid operation.
Google Drive in Lightning

2. In Salesforce classic, go to any Salesforce object, under Feeds > Files > Select a file from Salesforce:

Classic: Select a file from Salesforce

3. Then you see Google Drive and all its related files. Select any random file to perform a valid operation.

4. Moreover, you may launch the new tab created using the new external object items_Google_Drive in one of the earlier steps and see all the records to verify the Google drive data in Salesforce.

Refresh to view all Google Drive files

Congratulations, it confirms that Salesforce to Google Drive integration is working perfectly.❤️

References:

https://help.salesforce.com/s/articleView?id=sf.admin_files_connect_google_auth.htm&type=5

Developer details:

Please reach out to me for any suggestions or feedback. Would love to hear them ❤ If you loved this post, please applaud me at the end of this post with a 👏

--

--

Sombir Sheoran
Sombir Sheoran

Written by Sombir Sheoran

I'm a Certified Salesforce Consultant ☁️ who loves to write technical blogs, which help simplify Salesforce solutions. Follow to learn more ✨⚡

Responses (1)