Introduction:
In today’s fast-paced digital world, businesses increasingly rely on cloud-based applications to improve efficiency and collaboration. Two of the most powerful tools available today are Salesforce, a leading customer relationship management (CRM) platform, and Google Drive, a widely used cloud storage service. By integrating these applications, companies can streamline their processes, ensuring seamless data access and collaboration across teams. This integration eliminates the need for manual file sharing or switching between platforms, enhancing productivity and reducing operational bottlenecks.
The ability to share, manage, and collaborate on files directly from within Salesforce simplifies workflows and improves user experience. Google Drive’s secure cloud storage combined with Salesforce’s robust CRM functionality creates a unified system where data is centralized and easily accessible. With the integration, your team can attach Google Drive files to records, share documents with colleagues, and ensure everything is stored safely in the cloud, making business operations more efficient and streamlined.
Why is Integrating Salesforce and Google Drive Important?
Integrating Salesforce with Google Drive is crucial for businesses aiming to streamline workflows and enhance productivity. In many organizations, Salesforce is the backbone of customer relationship management, while Google Drive is a vital tool for document storage and collaboration. Without integration, teams often waste time switching between these platforms, manually uploading files, or copying data across systems, which increases the risk of errors and inefficiencies. By connecting Salesforce and Google Drive, businesses can create a seamless link between their customer data and important documents, ensuring that all information is centralized, easily accessible, and up-to-date. This integration reduces the administrative burden on employees, allowing them to focus on core tasks such as customer engagement, sales, and project management.
Steps to Integrate Google Drive with Salesforce:
1. Create an App in the Google Cloud Console
To begin, you’ll need to create a project in the Google Cloud Console to obtain the necessary credentials for the integration.
A. Access the Google Cloud Console:
- Navigate to the Google Cloud Console.
B. Create a New Project:
- Click on the project dropdown and select “New Project” if you don’t have one already.
- Provide a Project Name and click “Create”.
C. Enable APIs and Services:
- In the Dashboard, click on “Enable APIs and Services”.
- Search for and enable the following APIs:
- Google Drive API
- Google Picker API
D. Configure the OAuth Consent Screen:
- Navigate to “APIs & Services” > “OAuth consent screen”.
- Select “External” for user type and click “Create”.
- Fill in the required fields:
- App Name
- User Support Email
- App Logo (optional)
- Developer Contact Information
- Click “Save and Continue”.
- In the “Scopes” section, add the following scope:
- Complete the consent screen setup.
E. Create Credentials:
- Go to “APIs & Services” > “Credentials”.
- Click on “Create Credentials” and select “OAuth client ID”.
- Choose “Web application” as the application type.
- Provide a Name for your client ID.
- Under “Authorized redirect URIs”, you can leave this blank for now (we’ll update it later).
- Click “Create”.
- Note down the Client ID and Client Secret.
2. Configure Salesforce Authentication Provider:
Next, we’ll set up an authentication provider in Salesforce to handle the OAuth flow with Google.
A.Navigate to Auth. Providers in Salesforce:
- In Salesforce Setup, search for “Auth. Providers” and click “New”.
B. Select Provider Type:
- Choose “OpenID Connect” as the provider type.
C.Enter Provider Details:
- Name: Enter a recognizable name (e.g., “GoogleDriveAuth”).
- Consumer Key: Paste the Client ID obtained from Google Cloud Console.
- Consumer Secret: Paste the Client Secret from Google Cloud Console.
D.Configure Endpoints:
- Authorize Endpoint URL:
https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force
- Token Endpoint URL:
https://oauth2.googleapis.com/token - Default Scopes:
https://www.googleapis.com/auth/drive
E.Save and Copy the Callback URL:
- After saving, Salesforce will generate a Callback URL.
- Copy this URL; you’ll need to add it to your Google Cloud Console.
3. Update Google Cloud Console Credentials:
Add Authorized Redirect URI:
- Go back to the Google Cloud Console.
- Navigate to “APIs & Services” > “Credentials”.
- Edit your OAuth client ID.
- Under “Authorized redirect URIs”, paste the Callback URL copied from Salesforce.
- Save your changes.
Note:Ensure that the domain of the Callback URL is added to the Authorized Domains list in the OAuth consent screen.
4. Add Remote Site Settings in Salesforce:
A.Navigate to Remote Site Settings:
- In Salesforce Setup, search for “Remote Site Settings” and click “New Remote Site”.
B.Create a New Remote Site:
- Remote Site Name: Enter a name like “GoogleAPIs”.
- Remote Site URL: Enter https://www.googleapis.com.
- Save the new remote site.
5. Create a New Visualforce Page:
Now, we’ll create a Visualforce page that utilizes the Google Picker API to interact with Google Drive.
A.Navigate to Visualforce Pages:
- In Salesforce Setup, search for “Visualforce Pages” and click “New”.
B. Create the Visualforce Page:
- Label: Enter a name like “GoogleDriveIntegration”.
- Name: This will auto-populate based on the label.
- Content: Paste the following code, replacing placeholders with your actual keys:
<apex:page showHeader=”true” sidebar=”false” standardStylesheets=”false” docType=”html-5.0″>
<script type=”text/javascript”>
// The Browser API key is obtained from the Google API Console.
// Replace with your own Browser API key, or your own key.
var developerKey = ‘AIzaSyCBPNCs3tdQePgF0zUac4ua3bhCDD9-Byg’;
// The Client ID was obtained from the Google API Console. Replace with your own Client ID.
var clientId = “340258919089-24i3olodcgptipdvd8h5ru4esnf5nog8.apps.googleusercontent.com”
// Replace with your own project number from console.developers.google.com.
// See “Project number” under “IAM & Admin” > “Settings”
var appId = “340258911289”;
// Scope to use to access user’s Drive items.
var scope = [‘https://www.googleapis.com/auth/drive.file’];
var pickerApiLoaded = false, oauthToken, loadAuth=false;
// Use the Google API Loader script to load the Google.picker script.
function loadPicker() {
gapi.load(‘auth’, {‘callback’: onAuthApiLoad});
gapi.load(‘picker’, {‘callback’: onPickerApiLoad});
}
function onAuthApiLoad() {
if(loadAuth==true) {
window.gapi.auth.authorize(
{
‘client_id’: clientId,
‘scope’: scope,
‘immediate’: false
},
handleAuthResult);
}
}
function onPickerApiLoad() {
pickerApiLoaded = true;
createPicker();
}
function handleAuthResult(authResult) {
if (authResult && !authResult.error) {
oauthToken = authResult.access_token;
createPicker();
}
}
// Create and render a Picker object for searching images.
function createPicker() {
if (pickerApiLoaded && oauthToken) {
var picker = new google.picker.PickerBuilder()
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
.enableFeature(google.picker.Feature.SUPPORT_DRIVES)
.setAppId(appId)
.setOAuthToken(oauthToken)
.addView(new google.picker.DocsView(google.picker.ViewId.DOCS).setIncludeFolders(true).setSelectFolderEnabled(true))
.setDeveloperKey(developerKey)
.setCallback(pickerCallback)
.build();
picker.setVisible(true);
}
}
// A simple callback implementation.
function pickerCallback(data) {
if (data.action == google.picker.Action.PICKED) {
var fileId = data.docs[0].id;
}
if( data[google.picker.Response.ACTION] === google.picker.Action.PICKED ) {
var downloadUrl;
if( data.viewToken[0] === “upload” ) {
downloadUrl = data[google.picker.Response.DOCUMENTS][0].downloadUrl;
}
else {
downloadUrl = data[google.picker.Response.DOCUMENTS][0].url;
}
document.getElementById( “result” ).innerHTML = downloadUrl;
document.getElementById( “result” ).setAttribute( “href”, downloadUrl );
}
}
function uploadFiles() {
loadAuth = true;
onAuthApiLoad()
}
</script>
<a onclick=”uploadFiles()”>
<div class=”slds-text-heading_large”>Open GDrive</div>
</a>
<a id=”result” target=”_blank”></a>
<!– The Google API Loader script. –>
<script type=”text/javascript” src=”https://apis.google.com/js/api.js?onload=loadPicker”></script>
</apex:page>
Below Image Is The Preview Of The Visualforce Page:-
C. Replace Placeholders with Actual Values:
- YOUR_DEVELOPER_KEY: Replace with your API Key from Google Cloud Console
- YOUR_CLIENT_ID: Replace with your Client ID.
- YOUR_APP_ID: Replace with your Project Number (found under “IAM & Admin” > “Settings” in Google Cloud Console).
D. Save the Visualforce Page:
- Click “Save” to create the page.
Benefits of Integrating Salesforce and Google Drive:
- Increased Efficiency: The integration eliminates the need to manually transfer files or data between Salesforce and Google Drive, saving time and reducing repetitive tasks. Users can upload, access, and share Google Drive files directly from within Salesforce, streamlining the workflow.
- Enhanced Collaboration: Teams can easily collaborate on documents stored in Google Drive without leaving Salesforce. Multiple users can access the same file simultaneously, making real-time collaboration smoother and more efficient.
- Centralized Data Access:> All customer-related documents are stored in a centralized location and linked to Salesforce records. This ensures that team members have quick access to the most current and relevant files, improving data accuracy and decision-making.
- Improved Security and Compliance: Google Drive offers robust security features, such as encrypted storage and detailed access controls. When integrated with Salesforce, businesses can ensure that all important files are securely stored, reducing the risk of data breaches and meeting compliance requirements.
- Scalability and Flexibility: The integration is highly scalable, allowing businesses of all sizes to benefit from it. As your organization grows, the integration can handle increasing amounts of data and files, offering flexibility to accommodate changing business needs.
- Better User Experience: A unified system where all data and documents are accessible within Salesforce provides a more intuitive user experience. This reduces training time for new users and increases productivity for existing users by simplifying navigation and task management.
Conclusion:
By following these steps, you’ve successfully integrated Google Drive with Salesforce, enabling you to access, upload, and manage your Google Drive files directly from Salesforce. This integration enhances collaboration and streamlines your workflow by centralizing document management within your CRM platform.
Note: Always ensure that you handle API keys and client secrets securely. Do not expose them in client-side code or share them publicly.
Contact Us
We would love to hear from you Please feel free to send us a message via the form