Salesforce to Google Drive Integration is crucial for many businesses. It improves team collaboration by facilitating real-time synchronization of Google Sheets, Docs, Slides, and forms to an opportunity, account, or customer contact in Salesforce. As Salesforce analyzes data and generates reports, this integration proves beneficial with real-time updates, business process optimization, multi-level data security, increased storage, and reduced cost.

So, if you are looking to integrate Salesforce with Google Drive, Here are the steps and code to get a seamless integration experience.

Steps to Integrate Salesforce to Google Drive :

Step 1: Create an Authentication Provider for Google Drive

To use Google Drive as an external data source, create an authentication provider for it in Salesforce. The process begins with creating a related project in the Google Developers console.

Create a Project in the Google Developers Console :

  1. Log in to https://console.cloud.google.com.

2.  Select Project and click Create Project.

3. Enter a project name and location, and click Create.

Salesforce to Google Drive Integration1

4. In the project dashboard, click the menu icon in the upper left, and then click APIs & Services.

Salesforce to Google Drive Integration2

5. In the API manager, go to the Library tab and search for Google Drive API.

6. In the search results, click Google Drive API and Enable API.

Salesforce to Google Drive Integration3

7. In the menu on the left, click Credentials.

8. In the OAuth Consent Screen tab, enter a valid email address and application name, and click Save.

9. In the Credentials tab, click Add credentials and select OAuth client ID.

Salesforce to Google Drive Integration4

10. Select Web application, and click Create.

11. Copy the client ID and client secret values to a text file. Use these values when creating an authentication provider in Salesforce.

Step: 2 Create an Authentication Provider in Salesforce

In Setup, enter Auth. Providers in the Quick Find box, then select Auth. Providers. Click New.

  • For Provider Type, select OpenID Connect, and then set the following options:
  • Name — Enter the name you want to appear in Salesforce.
  • URL Suffix — Enter the suffix at the end of the URL path. For example, in the path, https://login.salesforce.com/services/authcallback/00Dx00000000001/MyGoogleProvider, the suffix is “MyGoogleProvider”
  • Consumer Key — Enter the client ID you copied when creating the Google project.
  • Consumer Secret — Enter the client secret you copied when creating the Google project.
Salesforce to Google Drive Integration5

2. Authorize Endpoint URL —Enter

https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force

 

  • Token Endpoint URL — Enter https://accounts.google.com/o/oauth2/token
  • Default Scopes — Enter openid email profile https://www.googleapis.com/auth/drive
  • Click Save. Then, at the bottom of the Auth. Provider detail page, copy the Callback URL entry to a text file. (Use this URL when editing the Google project.)
  • Edit the Project in the Google Developer Console
  • In the API Manager, in the menu on the left, click Credentials.
  • Click the previously created web app.
  • In the Authorized Redirect URIs section, add the Callback URL you copied when creating the authentication provider in Salesforce, and click Save.

3. Now we will create Named Credential in Salesforce :

  • Go to Setup and search for Named Credentials.
  • Click on New Named Credential.
  • For Label give GoogleDrive.
  • For URL use https://www.googleapis.com/drive/v2.
  • For Identity, Type choose Named Principal.
  • Choose OAuth 2.0 for Authentication Protocol.
  • For Authentication Provider choose GoogleAuth (we created auth provider in step 2).

4. Check Start Authentication Flow on the Save checkbox and click on Save.
5. After saving it will redirect to the google login page, login with your account.
6. Next, we will get a screen asking for permission to allow access to Google Drive

Salesforce to Google Drive Integration6

7. Click on Allow, next we will see a confirmation dialog, click Allow again.

 

8. After this we will be redirected to the Named Credential detail page. Here we will see Authentication Status as Authenticated.

Step 3: Now we will make a callout and get the Attachment in our Google Drive Account.

Open Developer Console and paste the Below codes

Code

Trigger:

Batch to Handle File

Utility Class:

Note : Create fields in the classes if needed , which are available in code.

Conclusion

So, here it is, our strategic guide to integrating Salesforce with Google Drive. Try out the solution and share your experience with us. Also, stay tuned to our blogs for more interesting Salesforce development services. Catch you on the next one. Happy Learning!

Related Articles
Step-by-Step Guide to Enhance Your LWC Development Workflow with the Logger API

Are you looking to streamline your LWC development workflow but confused about how to do it? Then you are in the right place. The Salesforce Logger API is a powerful tool that helps you monitor, debug, and improve code quality in real time.  This step-by-step guide walks you through how to set it up and […]

Read More
Enhancing Your Salesforce Experience with a Custom Activity Component

In today’s fast-paced business landscape, productivity hinges on streamlined workflows and intuitive interfaces. While Salesforce offers robust activity tracking capabilities, sometimes the standard components fall short of specific organizational needs.  That’s where a Custom Activity Component comes in—designed to tailor your activity management experience, boost user efficiency, and provide deeper insights into customer interactions. In […]

Read More
Step-by-Step Guide to Integrating Salesforce Doc-Gen with eSigning Tools

In today’s fast-paced digital landscape, streamlining document workflows is no longer a luxury—it’s a necessity.  Integrating a document generation app, like Docs Made Easy, with an eSigning tool, helps businesses automate the entire document lifecycle—from creation to signature—saving time, reducing errors, and boosting productivity. In this guide, we’ll walk you through the key steps, tools, […]

Read More
How to Build a Real Time Chat Application Using LWC and Models API

The Models API plays a significant role in providing access to and facilitating interaction with large language models (LLMs) from various Salesforce partners such as Anthropic, Google, and OpenAI. It enables applications to leverage these models for various tasks, including text generation and other AI-powered capabilities. As a user, you can configure any Salesforce-enabled model […]

Read More
How to Integrate Salesforce Data Cloud with Amazon Redshift

Companies can finally connect Amazon Redshift to Salesforce Data Cloud without using the ordinary username & password authentication systems ever since its collaboration with AWS has happened. Business owners no longer have to be concerned about managing static credentials or breaching data security. By leveraging Salesforce IDP, companies can easily access their data lakehouse in […]

Read More
Trigger Prompt Templates Using Flow, Apex, or REST API

A prompt template is a pre-designed structure in Salesforce, specially designed to create personalized prompts by filling the substitute with particular details of customers, products, and more. This approach strengthens the creation of prompts and lets teams generate data-driven content. Every time a prompt template is used, it automatically merges the data to create a […]

Read More
Our Location worldwide
Indian Flag India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203117884
United States of America Flag USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
United Kingdom Flag UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
Canada Canada
HIC Global Solutions INC
43 Lafferty Lane, Richmond Hill, L4C 3N8, CA +1(262) 310-7818