Search code examples
google-apigoogle-calendar-apigoogle-oauth

Google API Logging In Server Side


I want to make a web application (php - javascript) to do this:

  1. the user enter their google account email address
  2. the server then receive the user input -> let's say it's saved in variable useremail
  3. the server then log in as [email protected] with password somepassword to Google Calendar
  4. the server (now logged in as [email protected]) will edit an event in its google calendar (I have the event id), add the useremail to google calendar attendees (use Google Calendar API), then save the event
  5. the user will find on his/her google calendar that he/she had been invited to an event by [email protected]

I have tried google calendar javascript quickstart, but I don't want to make the user need to log in every time, just let them enter their email address (this is the requirement)

The question is:

  1. is it possible?
  2. how to do this? (given that I have [email protected], its password, and a user input containing a google email address)

Solution

  • The only way to access Google APIs is though Oauth. You are going to need to request access from the user and get a refresh token back. Once you get the refresh token you can use that at anytime to access the users google calendar account.

    You can not get an access token back with JavaScript you will need to use a server sided language. This might help Authorizing requests to Google calendar api