Introduction
S-Docs connects seamlessly with Google Drive, meaning that you can generate documents securely on the Salesforce platform and then upload them to Google Drive right away -- all without ever leaving Salesforce. This article will provide you with step-by-step instructions for configuring the S-Docs and Google Drive integration.
The S-Docs package already includes all needed components that allow it to work with Google Drive. However, your admin will need to complete the following steps to enable the feature.
Step 1: Create a Named Credentials for Google Drive
Create a Google Client
- Navigate to the Google Cloud Platform.
- Click on the project dropdown on and click NEW PROJECT
- After the project is completed, on the left side menu select APIs & Services -> Credentials
- Click the + CREATE CREDENTIALS on the top menu and select OAuth client ID
- Choose Web Application for application type - the name does not matter.
- Leave everything blank for now and just click create:
- After clicking create, a popup will appear that has the Client ID and Client Secret, keep those two saved since we’ll need it later.
- Click “OK” and click on your new credential.
- Locate Authorized redirect URLs, click on + ADD URI, and insert:
https://[my.salesforce.com Domain URL]/services/authcallback/GoogleAuthExample: https://example.my.salesforce.com/services/authcallback/GoogleAuth - Click Save
Create Auth. Provider in Salesforce
- Navigate to the Auth. Providers page through Setup
- Click “New” to create a new auth provider and select Provider Type: Open ID Connect.
- Fill in the credentials
Name: Anything
URL suffix: Anything that matches with the name
Consumer Key: saved Client ID
Consumer Secret: saved Client Secret
Authorize Endpoint URL: https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force
Token Endpoint URL: https://oauth2.googleapis.com/token
User Info Endpoint URL: leave blank
Token Issuer: leave blank
Default Scopes: openid https://www.googleapis.com/auth/drive
Send access token in header: Checked
Send client credentials in header: Unchecked
Include Consumer Secret in SOAP API Responses: Checked - After clicking save, a Salesforce Configuration will appear under Auth. Provider Detail. Save the Callback URL.
Step 2: Add Named Credentials to Salesforce
- Navigate to Named Credentials from Settings and click New Named Credential
- Fill in the following
Label: GoogleDriveUpload
Name: GoogleDriveUpload
URL: https://www.googleapis.com/upload/drive
Identity Type: Named Principal
Authentication Protocol: OAuth 2.0
Authentication Provider: Click the find icon on the right and select the Auth. Provider created previously
Scope: openid https://www.googleapis.com/auth/drive
Start Authentication Flow on Save: Checked
Generate Authorization Header: Checked
- Upon clicking Save, the page will be redirected to the google Oauth page. Go through the process of authenticating the desired google drive account and it’ll redirect back to the salesforce named credentials page.
Step 3: Add Google Docs Enabled Checkbox to Template Detail Page & Activate Templates for Google Drive
Administrators are able to determine which documents are eligible for upload to Google Drive with the Google Docs Enabled checkbox. This checkbox is not visible by default, however, and must be added to the template detail page layout.
From the Setup menu, navigate to the Object Manager and find the SDoc Template object.
Navigate to the Page Layouts tab, click the dropdown arrow for the SDoc Template page layout, and click Edit.
Navigate to the Fields tab, find the Google Docs Enabled field, and drag it down into the SDoc Template Detail section. Click Save.
This checkbox will now appear on all template detail records. You can now check it to determine whether new documents generated with this template can be uploaded to Google.
For more information on generating and uploading S-Docs documents to Google Drive, please review our guide Using Google Drive.
Step 4 (Optional): Specify A Google Drive Folder
By default, all S-Docs uploaded to Google Drive will be stored in the user's base Google Drive folder. You can specify a different folder to upload your document to at the template level.
If your template is Google Docs enabled, the Document Options tab in the template editor will contain additional Google Drive options where this can be configured.
[1] To specify which folder documents generated using this template should be stored within, paste the folder ID into this field.
[2] Check this box to upload your document to Google Drive in its native format. By default, all documents uploaded will be converted to Google Docs. This checkbox will cause a PDF to upload as a PDF instead of a Google Doc.