I'm creating a Vue app in which I'm implementing auto login functionality with Firebase. I'm calling the autoLogin function below, which gets the token for the signInWithCustomToken function from the browser's local storage. As a result, I'm getting the 400 error, and the Firebase error for "invalid custom token". It looks as though I'm sending a different token, while I see the correct one provided to the signInWithCustomToken function in the browser console. I'm doing something wrong but I'm unable to figure out what that might be.
autoLogin() {
let token = localStorage.getItem('token');
console.log('localstorage token: ', token);
console.log('autologin');
signInWithCustomToken(auth, token)
.then(userCredential => {
// Signed in
console.log(userCredential);
})
.catch(error => {
console.log('catch block:');
const errorCode = error.code;
console.log(errorCode);
const errorMessage = error.message;
console.log(errorMessage);
// ...
});
