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

TokenStorage not working correctly #8

Closed
espling opened this issue May 5, 2020 · 9 comments
Closed

TokenStorage not working correctly #8

espling opened this issue May 5, 2020 · 9 comments

Comments

@espling
Copy link

espling commented May 5, 2020

Hi

I've a problem with TokenStorage. I'm using OAuth2Helper.AUTHORIZATION_CODE with scope parameters ['api', 'openid', 'profile']. After login i'm trying to do a get. But the token is null from TokenStorage and i'm prompt to login again. There seems to be a problem with the scopeKey not being correctly defined when writing and getting tokens from TokenStorage.

@okrad
Copy link
Collaborator

okrad commented May 5, 2020

Hi, what happens when you authenticate for the second time? Does the token get created?
Would you mind providing a code sample?

@ResoDev
Copy link

ResoDev commented May 5, 2020

Hello! Same here.
I'm using the GitHub API and this issue occurs because the scopes we provide to the OAuthClient are list of strings: ['repo', 'notifications']. The scopes which are returned from GitHub are, however, not a list of strings but instead one long string 'repo;notifications'.
It seems that at least for the GitHub API, the solution would be to split the response string at ;.

@espling
Copy link
Author

espling commented May 6, 2020

Trying to explain a bit more without a code sample.

I'm using scopes ['api', 'openid', 'profile'].

For me the getToken method sets scopeKey to 'api__openid__profile'.

The insertToken method, scopeKey is set to 'openid profile api'.

The tokens map is set to:
{
openid profile api: {http_status_code: 200, access_token:..}
}

@espling
Copy link
Author

espling commented May 6, 2020

I saw that I've had wrong order in my scope list.

The scopes that returned token contains is [openid profile api]. A different order than my configuration. But even if a change my configuration to exactly that order to: ['openid', 'profile', 'api'] it still doesn't work.

On this line scopeKey is openid__profile__api.
if (tokens.containsKey(scopeKey))

But the tokens key is :
{openid profile api: {...

Hope that explains it a bit more.

@okrad
Copy link
Collaborator

okrad commented May 6, 2020

Hi @jimad7 and @ResoDev, thank you for taking the time of looking into the issue!
You are both right: the scopes that are sent from GitHub are a comma-separated list (instead of space-separated as by the rfc)... We need to handle this exception.
Furthermore the scope key generation method must take into account the order of the scopes.

I'm already working on these issues, fixes should be released very soon.

@okrad okrad closed this as completed in 53c0042 May 7, 2020
@okrad
Copy link
Collaborator

okrad commented May 7, 2020

Just published version 1.2.3... Does it solve your issues?

@okrad okrad reopened this May 7, 2020
@ResoDev
Copy link

ResoDev commented May 9, 2020

It does for me. Thank you!

@espling
Copy link
Author

espling commented May 10, 2020

Hi, it does for me too. Thank you!

@okrad
Copy link
Collaborator

okrad commented May 10, 2020

Fine!

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

3 participants