0% found this document useful (0 votes)
6 views9 pages

Integrate Salesforce To Google Drive

The document outlines the steps to integrate Salesforce with Google Drive, enhancing team collaboration through real-time synchronization of various Google services. It details the process of creating an authentication provider in Salesforce, setting up credentials in the Google Developers console, and establishing a named credential in Salesforce. The document concludes with instructions for making a callout to retrieve attachments from Google Drive using Apex code.

Uploaded by

Gaurav Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views9 pages

Integrate Salesforce To Google Drive

The document outlines the steps to integrate Salesforce with Google Drive, enhancing team collaboration through real-time synchronization of various Google services. It details the process of creating an authentication provider in Salesforce, setting up credentials in the Google Developers console, and establishing a named credential in Salesforce. The document concludes with instructions for making a callout to retrieve attachments from Google Drive using Apex code.

Uploaded by

Gaurav Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Integrate Salesforce to Google Drive

Kajal Yadav

Integration Use Case 1


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.
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.

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

Integration Use Case 2


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.

Note: Here API has been enabled already.

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

Integration Use Case 3


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.

10. Select Web application, and click Create.

Integration Use Case 4


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/MyGooglePro
vider, 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.

Integration Use Case 5


3. 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.

Step: 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).

Integration Use Case 6


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

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

Integration Use Case 7


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

Step 4: 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:

Apex Class:

Integration Use Case 8


Live Demo:

https://drive.google.com/file/d/1fUYL44JBTtI9vnZr9upay2bio4oYnNm_/view?usp=sharing

Integration Use Case 9

You might also like