Configure Google Drive with Named Credentials


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

  1. Navigate to the Google Cloud Platform.
  2. Click on the project dropdown on and click NEW PROJECT


  3. After the project is completed, on the left side menu select APIs & Services -> Credentials

  4. Click the + CREATE CREDENTIALS on the top menu and select OAuth client ID

  5. Choose Web Application for application type - the name does not matter.
  6. Leave everything blank for now and just click create:
  7. 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.
If you accidentally closed the popup window, click the credential you created under OAuth 2.0 Client IDs, and the information will be on the right side.
  1. Click “OK” and click on your new credential.
  2. Locate Authorized redirect URLs, click on + ADD URI, and insert:
    https://[ Domain URL]/services/authcallback/GoogleAuthExample:

  3. Click Save

Create Auth. Provider in Salesforce

  1. Navigate to the Auth. Providers page through Setup
  2. Click “New” to create a new auth provider and select Provider Type: Open ID Connect.
  3. 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:
    Token Endpoint URL:
    User Info Endpoint URL: leave blank
    Token Issuer: leave blank
    Default Scopes: openid
    Send access token in header: Checked
    Send client credentials in header: Unchecked
    Include Consumer Secret in SOAP API Responses: Checked

  4. After clicking save, a Salesforce Configuration will appear under Auth. Provider Detail. Save the Callback URL.

Step 2: Add Named Credentials to Salesforce

  1. Navigate to Named Credentials from Settings and click New Named Credential
  2. Fill in the following
    Label: GoogleDriveUpload
    Name: GoogleDriveUpload
    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
    Start Authentication Flow on Save: Checked
    Generate Authorization Header: Checked
  3. 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.

Was this helpful?