Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

jwtInterceptor - tokenGetter is not called because of angular caching #60

Closed
RayzRazko opened this issue Nov 20, 2015 · 6 comments
Closed
Labels
closed:stale Issue or PR has not seen activity recently

Comments

@RayzRazko
Copy link

Hi guys. I noticed that sometimes tokenGetter is not called during request and instead of sending refresh token request to fetch updated access token, interceptor just do nothing. As I understand angular caches headers and because of next lines the tokenGetter is not called:

request.headers = request.headers || {};
// Already has an Authorization header
if (request.headers[config.authHeader]) {
    return request;
}

Maybe it will be better to add configurable parameter, something like "forceHearedUpdate" and if this parameter is true then omit the if (request.headers[config.authHeader]) branch of code.

@windom
Copy link

windom commented Nov 25, 2015

Hi. I've noticed this too, but it happens in a very random fashion. Do you know any concrete methods to reproduce this? When does Angular cache the headers?

@RayzRazko
Copy link
Author

It's hard to define steps, but it happens really often.

@windom
Copy link

windom commented Nov 26, 2015

You could be right, by removing the header check the issue seemed to vanish. But it's strange nonetheless.

@windom
Copy link

windom commented Dec 2, 2015

I take back everything. My issue was different: in the tokenGetter method I checked if the token has expired and only then did I call the refresh API method. When the client clock and the server clock weren't in sync it could happen, that the client sees an expired token as valid and would not call the refresh method.

@tlkahn
Copy link

tlkahn commented Jul 5, 2016

Hi, maybe I am a bit late to the party. Is the issue solved now? Does adding a random string to the end of the URL help?

@stale
Copy link

stale bot commented Oct 26, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇‍♂️

@stale stale bot added the closed:stale Issue or PR has not seen activity recently label Oct 26, 2019
@stale stale bot closed this as completed Nov 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
closed:stale Issue or PR has not seen activity recently
Projects
None yet
Development

No branches or pull requests

3 participants