I have an angularfire authentication service which works absolutely fine - except it wont refresh the token.
My refresh code:
firebase.auth().currentUser.getIdToken(true).then((token: string) => {
const newUser = { token: token }; // new user details in brief
this.user.next(newUser);
});
calls the firebase service just fine and gives a response, but it only returns the current token and doesn't refresh the token - so it still logs out of the app after 1 hour.
I have read a multitude of issues regarding getIdToken but none which specifically address a token not refreshing.
I made a stackblitz: https://stackblitz.com/edit/angular-ivy-uvcdz7?file=src/app/app.component.ts so you can see the code in full (though it doesn't work for some reason, but also because I cant work out how to connect the project to firebase via SB)
edit
To help there are some other odd behaviours I dont expect, for example in my ngOnInit I have...
this.fAuth.onAuthStateChanged((state) => {
console.log(state);
})
which does nothing when I log in or out - no message to say the state has changed. None of these functions which I expect to trigger when things change in the authentication seem to do anything.
edit 2
As added info, before I added the bounty I did a full and painful update of Angular and AngularFire, so now Angular is v13 and AngularFire is 7.2.0 to see if this would make any difference, but it did not, the getIdToken still provides no refresh of the token.
from AngularFire getIdToken(true) not refreshing token
No comments:
Post a Comment