2

I'm currently using Firebase with Google Sign-In in an Angular project.

I would like to access the Google Calendar API. I think lot of steps described in the google documentation are unnecessary since Firebase Google Sign-In already return an access token and a refresh token.

Below is the code from the firebase documentation.

And it seems we can actually access the google API after the signInWithPopup method :

This gives you a Google Access Token. You can use it to access the Google API.

firebase.auth().signInWithPopup(provider).then(function(result) {
  // This gives you a Google Access Token. You can use it to access the Google API.
  var token = result.credential.accessToken;
  // The signed-in user info.
  var user = result.user;
  // ...
});

Here is my code where i added the calendar in the scope.

let provider = new firebase.auth.GoogleAuthProvider();
provider.addScope("https://www.googleapis.com/auth/calendar.readonly");

this.afAuth.auth.signInWithPopup(provider).then(function(result) {
  // ...
});

So, what is the next step? How do i actually access the calendar and let say, return a list of my calendars or list of events?

KENdi
  • 7,576
  • 2
  • 16
  • 31
Brieuc
  • 3,994
  • 9
  • 37
  • 70
  • 2
    Looks like this has been covered in various forms [1](https://stackoverflow.com/questions/44476822/access-scope-data-after-firebase-authentication) [2](https://stackoverflow.com/questions/39914899/using-firebase-auth-to-access-the-google-calendar-api) [3](https://stackoverflow.com/questions/44231468/firebase-auth-and-google-calendar-creation) [4](https://stackoverflow.com/questions/35195782/firebase-auth-and-google-calendar-using-polymer) [5](https://stackoverflow.com/questions/28932427/firebase-auth-and-google-calendar) – Kato Mar 13 '18 at 18:05
  • 2
    [This one](https://stackoverflow.com/questions/49182671/is-it-possible-to-add-events-to-a-users-google-calendar-via-firebase-server-sid/49183647#49183647) looks pretty good and includes an example of accessing the calendar and links out to more ref docs. – Kato Mar 13 '18 at 18:08
  • Awesome, thank you @Kato. I wanted to make sure it was up to date :). – Brieuc Mar 14 '18 at 13:02
  • try this, hopefully it can help _https://www.youtube.com/watch?v=Bj15-6rBHQw&t=393s&index=2&list=PLvdMKdx5hXZgP_x9kfF9E2KwTBf4s8O6Y_ – Denis Ramdan Feb 18 '19 at 03:58

0 Answers0