function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Varun99Varun99 

Is it possible to integrate salesforce apex with google calendar ?

hello,
is it possible to integrate using salesforce apex code with google calendar ?
i want to create from apex a simple event on google calendar.
i read about the google calendar api but i can't understand how to do it in apex.
is it possible ? can someone give me a simple example ?

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox
Yes, it can be done, but this is probably outside the scope of a simple response in the forums. It is a relative trivial task, but will require a number of steps to complete.

The basic flow is:

1) Authenticate with Google's OAuth service to get a token. This can be done with a popup.
2) Request the data you need access to.

To complete the first step, you'll have to create a Google API account that has a client secret/key pair that is enabled for at minimum calendar access (using whatever permissions you desire). From there, you can use the standard popup/login/authorize flow as documented on Google Developer (https://developers.google.com/accounts/docs/OAuth2).

Once you have an OAuth2 token, you can call the Google Calendar API. This will require setting up a Remote Access point in salesforce.com. Once you allow salesforce.com to connect out, you can use the JSON class to create requests, and parse responses, through the Google Calendar API.

Even this simple description doesn't do justice to the quantity of code you'll have to write, but it is well-documented if you'd like to take a shot at doing this.

All Answers

sfdcfoxsfdcfox
Yes, it can be done, but this is probably outside the scope of a simple response in the forums. It is a relative trivial task, but will require a number of steps to complete.

The basic flow is:

1) Authenticate with Google's OAuth service to get a token. This can be done with a popup.
2) Request the data you need access to.

To complete the first step, you'll have to create a Google API account that has a client secret/key pair that is enabled for at minimum calendar access (using whatever permissions you desire). From there, you can use the standard popup/login/authorize flow as documented on Google Developer (https://developers.google.com/accounts/docs/OAuth2).

Once you have an OAuth2 token, you can call the Google Calendar API. This will require setting up a Remote Access point in salesforce.com. Once you allow salesforce.com to connect out, you can use the JSON class to create requests, and parse responses, through the Google Calendar API.

Even this simple description doesn't do justice to the quantity of code you'll have to write, but it is well-documented if you'd like to take a shot at doing this.
This was selected as the best answer
Varun99Varun99

Hi,

 

 

Thank you for your reply. It will help for me. But you provided a link not working. Can you please

send any links? I have searched in google sales force provided tool kit 

http://wiki.developerforce.com/page/Google_Calendar_API Is it write way?

 

 

Thank you

sfdcfoxsfdcfox
https://developers.google.com/accounts/docs/OAuth2

Sorry, the forum added some characters to my link. The link above should work for the first bullet point.

It looks like the code provided in the link you posted should work as well. I wasn't aware such an article existed; it should still be trivial to implement anyways.
Varun99Varun99

Hi,

 

   Thanks for your reply. Can you share any sample code for getting token?

 

 

Thank you.

sfdcfoxsfdcfox
https://developers.google.com/accounts/docs/OAuth2 has the resources you should need. I don't have time to write a sample code today, but I'll see if I can do it in the near future.
Varun99Varun99

Hi ,

 

Thank you for your quick reply. It will help for my requirement.

 

 

Thank you

lakshmi ganapathirajulakshmi ganapathiraju
please share your code once varun
i  have same requirement
i am creating an event in google calender to use salesforce apex