On this Weblog, we’re going to Combine Salesforce with Google (Calendar, E-mail, Drive and so on.) REST API. For this text, we’re going to combine Google Calendar. You’ll be able to combine any Google API through the use of the below-mentioned strategies, you simply have to make adjustments based on API documentation.
Technique Used: – By Utilizing Auth. Supplier and Identify Credentials
Following are the steps to Combine Google Calendar REST API utilizing Auth. Supplier and Identify Credentials –
Step 1: Create an App on Google Developer Console
- Go to https://console.cloud.google.com/ and log in.
- Choose the Create button to create a brand new Challenge.
- Enter Challenge Identify and click on the create button.
- Choose ENABLE APIS AND SERVICES.
- Select the API wanted (For my activity I’ve chosen Google Calendar API).
- Go to OAuth consent display screen. Choose Exterior consumer kind then clicks create. Add the Software Identify, add Software Brand (if wanted) and what’s a vital choose scope. Scope outlined what kind of entry your app can assure and the obtainable scopes confer with google calendar documentation https://developers.google.com/calendar/api
- Create credentials, and select that OAuth shopper ID. Credentials are wanted to attach our Google challenge with Salesforce.
- Choose Internet Software, add some Identify, and go away different fields clean. We don’t know Licensed redirect URLs but.
Remember to take a look at: Salesforce Integration Using Oracle SOA Suite
If every little thing went nicely you need to obtain the Shopper ID and Shopper Secret.
- Click on Create Credentials->OAuth shopper ID
- Shopper ID and secret are seen
Step 2: – Configure Auth Supplier
- In Salesforce go to Setup > Auth. Supplier > New and choose Open ID Join.
- Enter Identify, Paste Shopper Key and Shopper Secret (from step1).
- Add endpoints:
- Authorize Endpoint URL > https://accounts.google.com/o/oauth2/v2/auth
- Token Endpoint URL > https://oauth2.googleapis.com/token
- As a default Scope use scopes outlined in your google app. e.g., e-mail.
After saving yow will discover Callback URL within the Salesforce Configuration part. Copy the hyperlink and paste it into your credentials (Credentials > OAuth 2.Zero shopper IDs).
- After saving you will see the callback URL and paste it on
- Credentials(Google App) > Edit OAuth Shopper ID > Licensed redirect URIs > Add URI
Try one other superb weblog by Parvez right here: Integration of Two Salesforce Org Using REST API – The Complete Guide
Step 3: – Create Named Credentials in Salesforce
- In Salesforce go to Setup > Named Credentials > New Named Credentials.
- Enter Identify,
URL – https://www.googleapis.com
Identification Sort – Named Principal
Authentication Protocol – OAuth 2.0
Authentication Supplier – Auth Supplier you created in step2
Scopes – https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/calendar.occasions
Begin Authentication Stream on Save – Examine it to authorize your Google account.
- Authorize your Google account.
- Enable for entry.
- If every little thing is okay, you need to be licensed as a consumer.
Step 4: – Distant Web site Settings
To make callouts we have to add our endpoint to distant web site settings.
- Go to Setup > Distant Web site Settings > New Distant Web site
Step 5: – Make Callouts
world static void getCalendar(){ request = new HttpRequest(); request.setMethod('GET'); request.setEndpoint('callout:_AUTH PROVIDER_/calendar/v3/calendars/main/occasions'); response = http.ship(request); }