Firebase authentication tokens expiration duration

2020-06-23 06:38发布

I just upgraded to the new version of Firebase and I can't find where I can set the expiration duration of my Firebase authentication tokens. It used to be under the authentication section in Firebase's old layout (I had it set for 1 year). Does Firebase still have this?

2条回答
Anthone
2楼-- · 2020-06-23 07:16

I am able to login to firebase using below code:

this.firebaseAuth
        .auth.signInWithCustomToken(this.token)
        .then(value => {
           var that=this;
           firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idToken) {
//get authorization token idToken here
}

I am able to to query firebase after login, but after refresh firebase not able to recognise the user?

I have stored token in localstorage but how to set token in angular firebase request? for below code:

this.afs.doc(
        `user/${user.uid}`
    ).set(Object.assign({}, auser), { merge: true });
查看更多
再贱就再见
3楼-- · 2020-06-23 07:18

If you keep using the Firebase 2.x SDK, your expiration period will be the same as before. You cannot change the value anymore though.

If you upgrade your code to use the 3.x SDK, it'll switch to user a never-expiring ID token and a quickly expiring access token. See this answer for more on that: Firebase authentication duration is too persistent

查看更多
登录 后发表回答