Skip to content
Advertisement

Google calendar api – can I reuse token form google?

Can I use token from FE, where user is authorized from Google to insert event into google calendar on backend? Flow is:

  • user uthorized by google on frontend (firebase and google)
  • fill form on FE and submit
  • on backend side save data into DB and post event on calendar

Can I reuse token from FE? How I can do that?

I try few solutions using GoogleAuthorizationCodeFlow, and every time I get HTTP 401 or link to authorization in logs…

Currently creation of service looks like:

JavaScript

Advertisement

Answer

Ok. I’ve found out how to do. First. Authorization with access token should be on front-end. I use angular and firebase for uthorization.

  • install gapi and gapi.auth2
  • create on google (https://console.cloud.google.com) app and authorization data for web client (OAuth 2.0)
  • then I authorize user in google

as below:

JavaScript

now I send acces token with header to back-end and there I can insert event on google or do whatever I want.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement