akinov
akinov

Reputation: 31

Firebase Google Auth offline access_type to get a refresh_token

We are using firebase with google authentication. We chose Google because our application makes Google API calls. We authorize these api calls with the access_token included in authorization payload that is returned from firebase. However, we are having trouble figuring out how to refresh the access_token after it expires.

We need a way to refresh this token without forcing the user to reauthorize. Ideally, I could request the offline access_type when requesting the firebase auth... Is it possible to get an offline access_type Google oauth token through Firebase so that Google will return a refresh_token? With a refresh_token, I think I can grab a new access_token for api calls.

I was trying this but its definitely not supported:

const provider = new firebase.auth.GoogleAuthProvider()
provider.addScope('https://www.googleapis.com/auth/calendar')
provider.setCustomParameters({ access_type: 'offline' }) // not work
firebase.auth().signInWithRedirect(provider)

Upvotes: 2

Views: 445

Answers (1)

Arosha
Arosha

Reputation: 1401

Unfortunately, it is not currently possible to get a Google OAuth refresh token via Firebase Use separate code like in here to get access token/refresh token, in addition to firebase auth.

Firebase auth's access_token/refresh_token does not work for Google APIs

Upvotes: 0

Related Questions