React-redux-firebase: Does the accessToken in the stsTokenManager refresh automatically ?

Created on 10 Nov 2018  路  3Comments  路  Source: prescottprue/react-redux-firebase

Hi, Does the accessToken in the stsTokenManager refreshes automatically ?
If so, whats the name of the action ?
if not, whats the best practice to refresh it?

the token is expired after 60 minutes. i want to refresh it before its happened.

Thanks

Most helpful comment

I believe what you want is Firebase's getIdToken or getIdTokenResult. As mentioned in the docs passing true to getIdToken should automatically refresh it:

firebase.auth().currentUser.getIdToken()
  .then((token) => {
    console.log('the token is', token)
  })
  .catch((err) => {
    console.error('Error refreshing id token', err)
  })

Going to close since this is part of Firebase's JS SDK and not react-redux-firebase directly. If you have ideas around how to make this more clear, please feel free to post.

All 3 comments

I believe what you want is Firebase's getIdToken or getIdTokenResult. As mentioned in the docs passing true to getIdToken should automatically refresh it:

firebase.auth().currentUser.getIdToken()
  .then((token) => {
    console.log('the token is', token)
  })
  .catch((err) => {
    console.error('Error refreshing id token', err)
  })

Going to close since this is part of Firebase's JS SDK and not react-redux-firebase directly. If you have ideas around how to make this more clear, please feel free to post.

I need to have access to the latest auth token and I thought that stsTokenManager had the latest token. It would be nice to dispatch an action when the token refreshes. Something like:

firebase.auth().onIdTokenChanged.(token => dispatch({type: "tokenRefreshed", token}))

Is stsTokenManager.accessToken used for something internally?

@Wgil I don't believe it is - feel free to open a new issue to request that as a feature so we can track

Was this page helpful?
0 / 5 - 0 ratings