-
Notifications
You must be signed in to change notification settings - Fork 992
Description
[REQUIRED] Describe your environment
- Operating System version: Android 11
- Browser version: Chrome Beta Android 97.0.4692.45
- Firebase SDK version: 9.6.1
- Firebase Product: auth
[REQUIRED] Describe the problem
My PWA forcefully signs out the user if accessed offline after an extended period has passed. The result is not being able to use the app again until a connection is found and the user can sign back in. From the console log it appears that a call to getIdTokenResult() is failing and may (?) be the issue.
I'm seeing a similar (same?) app behavior on iOS 15 in Safari on an iPad MIni, but am unable to confirm what is actually happening in terms of errors.
Steps to reproduce:
- Log in to the app while online.
- Set the device to offline mode.
- Note that that app is fully usable while offline. Force reloading the app doesn't cause an issue, nor does force-closing and then reopening it. The app continues to function normally offline.
- Wait for about an hour or more and try to reload the app. It immediately routes to the login page and has errors in the console.
- Go online, sign back in, go back offline, and the app behaves again normally like in step number 3 above.
Relevant Code:
// vue.js v2 code (App.vue)
methods: {
getAndSetUserData () {
onIdTokenChanged(auth, (user) => {
this.hasUser = !!user?.uid;
if (this.hasUser) {
const { email, uid } = user;
this.$store.commit('CURRENT_USER', { email, uid });
this.getUserClaimsStatus(email);
}
});
},
async getUserClaimsStatus (email) {
const user = auth.currentUser;
const result = await getIdTokenResult(user);
const { program, env } = result.claims;
this.$store.commit('USER_PROGRAM', program);
const id = getAppInstanceId();
Sentry.configureScope(scope => scope.setUser({ email, id }));
}
}The Firebase getIdTokenResult docs mention the refreshing of the token when it expires. The failed call to securetoken.googleapis.com/v1/token?key=AIzaSy...8hOa8 seems somewhat suspect.
Though not the same version of firebase, or even the same OS environment, similar issues to mine have occurred elsewhere (e.g.#1104).
