Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access token not cached properly? #70

Open
petrovicnemanja opened this issue Jan 16, 2023 · 4 comments
Open

Access token not cached properly? #70

petrovicnemanja opened this issue Jan 16, 2023 · 4 comments
Assignees

Comments

@petrovicnemanja
Copy link

Hi, can you look into the code regarding _authenticationResponses? We were having a lot of issues with some mysterious 401 errors, and after some investigation it looks like the code isn't doing any proper caching of the tokens, ie. they are staying in memory indefinitely, even after they expire?

private static IList<AuthenticationResponse> _authenticationResponses;

@hyllengren hyllengren self-assigned this Jan 16, 2023
@cloveras
Copy link
Contributor

Interesting.. Will have the developers have a look.

As a general tip not related ti this: https://vippsas.github.io/vipps-developer-docs/docs/vipps-developers/faqs/common-errors-faq#why-do-i-get-http-401-unauthorized

@hyllengren
Copy link
Collaborator

@petrovicnemanja
They will stay in memory indefinately if no more requests for that market configuration happens:

_authenticationResponses.Remove(

So f.ex. if you have no requests for 24h, the token will be stored. But as soon as yo refresh the token it will be removed and replaced with the new token.

@petrovicnemanja
Copy link
Author

@hyllengren Thanks for the feedback. But when you say "refresh the token", there doesn't seem to be a mechanism for it, other than restarting/redeploying the whole application? Would you consider changing _authenticationResponses so that instead of IList<AuthenticationResponse> it's stored in ISynchronizedObjectInstanceCache or something similar? That way you can set it in cache with the expiration time from the response.

@valdisiljuconoks
Copy link
Collaborator

And thinking one step further - if it's stored in the cache under a well-known key, this opens up an option to flush "forcibly" (if needed) cache entry via some 3rd party tool (like cache viewer) to "reload" the token.

I hope this is rare case - but still an option for developers / site admins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants