Hello friends, In this post, I will show you how you can integrate Salesforce with Google Calendar so that Salesforce user could aware of all upcoming events and tasks!
Below is the list of all the tasks that we will do in this post to do Integrate Google Calendar with Salesforce.
Login into Your Salesforce Org and go to Setup -> Develop -> Custom Settings -> New
See below image for the field names and data types
Go to Using OAuth 2.0 to Access Google APIs and you will get Detailed Information about authentication process.
Go to Google API Console, Credentials -> Create Credentials -> oAuth Client Id
Application Type -> WEB
Authorized redirect URIs -> URL To Your VF page “You already have created the VF page if not follow the above steps and create both the pages with classes”
Open “GoogleCalenderoAuth” VF page, Click Preview and Copy the URL that URL is the Redirect URI paste that URL here.
Note: – You also need to replace “redirect_uri” variable in GoogleCalendarAPI class with your VF page URL.
Now, Click Create, a Pop up with Client Id and Client Secret will open
Copy both Client Id and Client Secret in any text Editor like notepad++, notepad, or any editor.
Now, Open GoogleCalenderApi class replace consumerKey with your Client Id and clientSecret with your Client Secret.
Now, as we have done all the necessary steps and it’s show time.
Open “GoogleCalenderoAuth” VF page, preview it Page will look like below
Click “Connect With Calendar” you will be redirected to Gmail Login, Login with your Gmail, Grant Access to Application. You will get back to the same Page and Now Click “Get Access Token” a new Page “GoogleCalendarActions” will open.
First, we will create a New Calendar, Enter “Testing Google API ” and then Create New Calendar. You will get a Success Message with the response.
Now, List All Calendars will list all the calendars that are available to your Account.
Note: – Using the Above Code of “GoogleCalenderoAuth” Page and “GoogleCalenderApi” Apex Class you can integrate with Any Google API. You only need to make a minor change which is the value of the calendar_Scope variable in GoogleCalenderApi class, use the scope of the API that you want to Connect. You will get the scope of all the APIs OAuth 2.0 Scopes for Google APIs.
Any Queries come in the comment section.
Please do like and share the same as sharing is caring 🙂