This page describes the Google Spreadsheet connector use case by integrating the spreadsheet connector with the Salesforce REST Connector. For example you can use the Salesforce REST Connector to get the account details (Eg :- Id, Name of the records in your organization) from Salesforce and add that account details into Google Spreadsheet using Google Spreadsheet connector.
...
- Download ESB 5.0.0 from here.
- Upload the following connectors to the ESB:
- Follow the instructions given in the developer guide of the above connectors.
- Import the certificate into the ESB client keystore to use the Salesforce REST connector. Refer this link to import the certificate.
- Creating the credentials to use the Google Spreadsheet connector:
Creating a Client ID and Client Secret
As the email sender, navigate to the URL https://console.developers.google.com/projectselector/apis/credentials and log in to your google account.
If you do not already have a project, create a new project and navigate to Create Credential -> OAuth client ID.
At this point, if the consent screen name is not provided, you will be prompted to do so.
Select the Web Application option and create a client. Provide https://developers.google.com/oauthplayground as the redirect URL under Authorized redirect URIs and click on Create. The client ID and client secret will then be displayed.
See Google Spreadsheet API documentation for details on creating the Client ID and Client Secret.
Click on the Library on the side menu, and select Google Sheets API. Click enable.
...
Follow these steps to automatically refresh the expired token when connecting to Google API:
- Navigate to the URL https://developers.google.com/oauthplayground and click on the gear wheel at the top right corner of the screen and select the option Use your own OAuth credentials. Provide the client ID and client secret you previously created and click on Close.
- Now under Step 1, select Google Sheets API v4 from the list of APIs and check all the scopes listed down and click on Authorize APIs. You will then be prompted to allow permission, click on Allow.
- In Step 2, click on Exchange authorization code for tokens to generate and display the access token and refresh token.
- Creating the credentials to use the Salesforce REST Connector:
- First, create a developer account in Salesforce using https://developer.salesforce.com/signup
- After, you need to create a connected app to get the clientId, clientSecret for getting the accessToken and refreshToken to access the Salesforce API.
If you have a Developer Edition account, log in to salesforce.com with your developer credentials, navigate to Setup ➤ Create ➤ Apps, and in the Connected Apps section, click New to create a new connected App.Then, Provide the App name, callback URL, Check Enable OAuth Settings to expand the API section and select the OAuth Scopes as below.
From these steps, you will get the Consumer key(Client ID) and Consumer Secret(Client Secret) for your app.
- Copy the following URL and paste it into a web browser URL bar and you have to replace the <your_client_id> and <your_redirect_uri> with the created app values. Then, you need to approve the application to access your salesforce account.
https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=<your_client_id>&redirect_uri=<your_redirect_uri>
- After, successful authorization, the user's browser is redirected back to the redirect URI at the client application, with a URL of the form:
https://www.yahoo.com/?code=aPrxqJ8A8kLOza.tLq5SDTDZbLiQ.tRsRLaXCIN0DsvDG5VK6F7_T6XDsDtRhHuchcJASkBCUA%3D%3D
The client application can now extract the authorization code from its URL parameter
.For that you just copy the below URL with the respected values for the application that created above
. You can set format as urlencoded, json or xml to getting the response as the specified format option.From the above response, you can get the accessToken to access the salesforce organization via the created app and refreshToken to refresh the accessToken when it will be expired.
https://login.salesforce.com/services/oauth2/token?code=aPrxqJ8A8kLOza.tLq5SDTDZbLiQ.tRsRLaXCIN0DsvDG5VK6F7_T6XDsDtRhHuchcJASkBCUA%3D%3D
==&grant_type=authorization_code&client_id=<your_client_id>&client_secret=<your_client_secret>&redirect_uri=<your_redirect_uri>&format=xml
...