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

OAuthService hasValidAccessToken wrongly returns true #1214

Closed
patrick-dedication opened this issue Mar 24, 2022 · 5 comments
Closed

OAuthService hasValidAccessToken wrongly returns true #1214

patrick-dedication opened this issue Mar 24, 2022 · 5 comments
Labels
bug For tagging faulty or unexpected behavior. investigation-needed Indication that the maintainer or involved community members may need to investigate more.

Comments

@patrick-dedication
Copy link

patrick-dedication commented Mar 24, 2022

Describe the bug
hasValidAccessToken returns true even though expired_at in local storage is a minute before now.

Additional context
the hasValidAccessToken function subtracts getClockSkewInMsec (10min by default) from now and compares the expiresAt against that value.
So a token is considered invalid only 10minutes after it it is expired

@jeroenheijmans jeroenheijmans added bug For tagging faulty or unexpected behavior. investigation-needed Indication that the maintainer or involved community members may need to investigate more. labels Mar 24, 2022
@jeroenheijmans
Copy link
Collaborator

Perhaps a duplicate of #1135?

@buchatsky
Copy link

buchatsky commented May 27, 2022

It also returns "true" if the Token endpoint erroneousely returns an empty JSON ("{}") in response body. In such case the library stores the string "undefined" as an access_token value, and hasValidAccessToken() returns "true".
I even don't dare create a new issue, looking at the number of opened ones)

@manfredsteyer
Copy link
Owner

When the access token response doesn't have an expiration time (which is also the case when it's an empty object), you can set the config property fallbackAccessTokenExpirationTimeInSec. This value is then used instead of the expiration time.

@manfredsteyer
Copy link
Owner

Feel free to reopen this issue if I'm wrong here.

@CedricHg
Copy link

CedricHg commented Mar 10, 2023

When the access token response doesn't have an expiration time (which is also the case when it's an empty object), you can set the config property fallbackAccessTokenExpirationTimeInSec. This value is then used instead of the expiration time.

I don't think I understand this comment, my access token response does have an expiration time so I don't need to use a fallback as far as I know. The bug the OP mentioned still happens.

edit: ok I understand now that I need to adjust "clockSkewInSec" in the auth config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug For tagging faulty or unexpected behavior. investigation-needed Indication that the maintainer or involved community members may need to investigate more.
Projects
None yet
Development

No branches or pull requests

5 participants