I am using firebase authentication with anonymous users. When the user sign up on the site, we link their credential.
Here is the code:
//Create the email and password credential, to upgrade the anonymous user.
let credential = firebase.auth.EmailAuthProvider.credential(email, visitorId);
//Link the credential to the currently signed in user (the anonymous user).
auth.currentUser.link(credential).then((user) => {
console.log("anonymous visitor successfully upgraded");
},
(error) => {
//error upgrading the anonymouse user
console.log("Error upgrading anonymous visitor", error);
});
Here is documentation of this approach
This has been working great until today. Now I am suddenly receiving an error code: auth/network-request-failed.
If I inspect the failed request in Fiddler, I find a response of:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "TOKEN_EXPIRED"
}
],
"code": 400,
"message": "TOKEN_EXPIRED"
}
}
The odd thing is that if I decode the token on the request, the expiration date falls in the future (about 1 hour ahead which is the default time length for their tokens). There is almost no delay between the time I generate the token, and the time I try linking it to the user. So why the failure?
My research:
The issue here sounds similar, but I has not resolved it for me.