Currently, my setup involves AWS Cognito for oauth authentication. Upon login, Cognito returns a token that needs to be refreshed every hour. I implemented logic using setTimeout to handle this token refresh every hour, but this method fails upon page refresh by the user. Is there an alternative solution available?
I attempted to use setTimeout and the interval feature from rxjs to refresh the token every hour, but encountered the same issue after a page refresh.
private async setAutoRefreshToken() {
return interval(3500000).pipe(startWith(1), switchMap(() => this.authService.refreshToken().pipe(map(auth => {
const data = auth.AuthenticationResult;
return data;
}))));
}