1

In firebase we can use signInWithPopup and get our auth provider access token by credential.accessToken. We can only get this accessToken one time after login. But this access token is expired in one hour! And we need to force user to login again to get access token. What the point of this completely useless access token user experience? If we cant use it anyway.

update: I'm developing Chrome Extension with Firebase and trying to add Google Calendar support. And I spent already several days but didn't found solution. first GAPI is not working in Chrome Extension. I tried to use signInWithPopup and make it with REST calls but google.com oauth2 access token in firebase is expiring after one hour and there is no way to refresh it silently. This is all Google products and why they are so hard to make work together?

update2:

provider = new firebase.auth.GoogleAuthProvider();
provider.addScope('https://www.googleapis.com/auth/calendar.events');

const result = await firebase.auth().signInWithPopup(provider)
var credential = result.credential;

// Saving **credential** somewhere for later use it in REST calls to` https://www.googleapis.com/calendar/v3/users/me/calendarList

PROBLEM this access token is expired after ONE hour.

rendom
  • 3,417
  • 6
  • 38
  • 49
  • 1
    This seems more like a rant/statement rather than a question that will solicit fact-based answers. The primary purpose of Firebase Authentication is to identify a user, if you wish to use the provider's token for more than just authenticating a user either reauthenticate when needed or take the user through the OAuth authentication flow yourself using Cloud Functions so you can store the refresh token securely in your database, tracking approved scopes, etc. – samthecodingman Apr 29 '21 at 08:39
  • @samthecodingman No it is a question, I honestly wondering why it is done in such way. Because in firebase v2 there was a way to access refreshed token unlimited times, and not only once immediately after login and only for a hour. – rendom Apr 29 '21 at 09:11
  • I'm with @samthecodingman here: it is hard for us to understand the problem through the clear frustration that you express with how the API works. I recommend taking a few steps back, and editing your page to show what you're trying to accomplish and how you tried to accomplish it. It's much more likely that someone is able to help with that. – Frank van Puffelen Apr 29 '21 at 14:55
  • @FrankvanPuffelen I'm developing Chrome Extension with Firebase and trying to add Google Calendar support. And I spent already several days but didn't found solution. first GAPI is not working in Chrome Extension. I tried to use `signInWithPopup` and make it with REST calls but google.com oauth2 access token in firebase is expiring after one hour and there is no way to refresh it silently. This is all Google products and why they are so hard to make work together? – rendom Apr 30 '21 at 02:27
  • Can you edit your question to show the [minimal code that reproduces the problem](http://stackoverflow.com/help/mcve)? – Frank van Puffelen Apr 30 '21 at 03:55
  • @FrankvanPuffelen added example code – rendom May 01 '21 at 04:13
  • Thanks. Now what's the problem you have when you run that code? What does it do? And what do you expect it to do instead? – Frank van Puffelen May 01 '21 at 14:25
  • @FrankvanPuffelen I'm developing Chrome Extension with Firebase and trying to add Google Calendar support. And I spent already several days but didn't found solution. first GAPI is not working in Chrome Extension. I tried to use signInWithPopup and make it with REST calls but google.com oauth2 access token in firebase is expiring after one hour and there is no way to refresh it silently. – rendom May 02 '21 at 15:22
  • Can you show how you are calling the Calendar API with the credentials from Firebase? This approach seems to have worked for some folks: https://stackoverflow.com/a/40108258 – Frank van Puffelen May 03 '21 at 13:43
  • @FrankvanPuffelen GAPI Google APIs JavaScript client is not available in Chrome Extension. – rendom May 04 '21 at 05:41

0 Answers0