MSAL2 AcquireTokenSilent not refreshing tokens correctly
Hello,
I have the following code in my interceptor for every http call. To obtain the accessToken, I call acquireTokenSilent and it works OK if the token is valid. If the token has expired it returns the following error:
InteractionRequiredAuthError: login_required: AADSTS50058: A silent sign-in request was sent but none of the currently signed in user(s) match the requested login hint.
Here is my sample code (where mailUser is the username of the logged in user in the application):
const silentRequest = {
scopes: scopes,
account: account,
loginHint: mailUser
};
return this.authService.acquireTokenSilent(silentRequest)
.pipe(
catchError((error) => {
if (error.name === "InteractionRequiredAuthError") {
**?????**
}
return EMPTY;
}),
switchMap((result: AuthenticationResult) => {
console.log("result.accessToken}");
})
);
How should I obtain the token in case of said error? I tried calling acquireTokenRedirect but it keeps refreshing the page on loop giving the same error
Thanks in advance