5

I am using Firebase's GoogleAuthProvider in my Vue 2 app to login user. I added the calendar to the provider's scope the get access to the user's calendar. I then use the access_token given in the result to retrieve the events. The problem is the accessToken expires after one hour. How can I renew it?

Here is my code to handle the login:

const auth = getAuth();
const provider = new GoogleAuthProvider();
provider.addScope("https://www.googleapis.com/auth/calendar");
const result = await signInWithPopup(auth, provider);
const credential = GoogleAuthProvider.credentialFromResult(result);
const token = credential.accessToken;
const user = result.user;
await this.checkUser(user, token);
MVT KVM
  • 168
  • 10
  • The access token can be renewed using the Refresh token that is provided during the token generation. The whole purpose of Refresh Token is to ensure that access token generation is done transparently. – Srinath Menon Nov 25 '21 at 05:16
  • @SrinathMenon Thank you for the response, I did read the documentation about that, however, there is no refresh token when you login the Firebase with the Google Auth Provider only an id token. Is this id token supposed to be the refresh token? – MVT KVM Nov 25 '21 at 07:08
  • See https://stackoverflow.com/questions/27890737/firebase-google-auth-offline-access-type-in-order-to-get-a-token-refresh?rq=1#comment44190563_27890737 - unfortunately this process doesn't get a refresh token – Alex L Jan 14 '22 at 07:54
  • Also see https://stackoverflow.com/a/49946656/1129194 – Alex L Jan 14 '22 at 07:55

0 Answers0