简体   繁体   English

firebase.auth().currentUser.getIdToken() 抛出“auth/user-token-expired”怎么办?

[英]What to do when firebase.auth().currentUser.getIdToken() throws “auth/user-token-expired”?

First, I didn't think this was possible.首先,我认为这是不可能的。 The documentation states:该文档指出:

"Returns the current token if it has not expired. Otherwise, this will refresh the token and return a new one." “如果尚未过期,则返回当前令牌。否则,这将刷新令牌并返回一个新令牌。”

So in what case would it throw this error?那么在什么情况下会抛出这个错误呢? If the refresh token expired, than why wouldn't it instead refresh it?如果刷新令牌过期,为什么不刷新呢? What is the best way to recover from this?从中恢复的最佳方法是什么? Set a timer and try again?设置一个计时器,然后再试一次? Seems like an anti-pattern.似乎是一种反模式。

This doesn't happen often.这并不经常发生。 I've seen it on safari iPhone, especially when waking up a tab that was signed in anonymously.我在 safari iPhone 上见过它,尤其是在唤醒匿名登录的标签时。

This happens when the user session is revoked or disabled.当用户 session 被撤销或禁用时,就会发生这种情况。 Revocation happens during big account changes, eg.撤销发生在大帐户更改期间,例如。 when the user updates their email or password in another session or the user sessions are revoked via the Admin SDK .当用户在另一个 session 中更新他们的 email 或密码或通过管理员 SDK撤销用户会话时。

The error will be thrown and the user is signed out and deactivated.将引发错误,用户退出并停用。 The expectation is to sign in again or re-authenticate the user.期望是再次登录或重新验证用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 自定义 Firebase 身份验证中的身份验证/用户令牌过期错误 - auth/user-token-expired error in custom firebase authentication Firebase currentUser.getIdToken() 在 signInWithCustomToken 之后返回自定义令牌 - Firebase currentUser.getIdToken() returns custom token after signInWithCustomToken 如何从“getFirebase().auth().currentUser.getIdToken()”获取字符串值 - How to get String value from “getFirebase().auth().currentUser.getIdToken()” firebase.auth()。当刷新页面时,currentUser返回null - firebase.auth().currentUser returns null when page is refreshed 使用 async/await 获取 firebase.auth().currentUser - Get firebase.auth().currentUser with async/await 试图使 firebase.auth().currentUser 成为 promise - Attempting to make firebase.auth().currentUser a promise javascript firebase.auth()。currentUser = null - javascript firebase.auth().currentUser = null firebase.auth().currentUser 在页面加载时为 null - firebase.auth().currentUser is null at page load firebase.auth 和 firebase.auth() 有什么区别? - What is the difference between firebase.auth and firebase.auth()? firebase.auth()。currentUser和onAuthStateChanged始终为null,尽管已登录 - firebase.auth().currentUser and onAuthStateChanged always null inspite of being signed in
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM