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

Output granted scopes in credentials block of the auth hash #420

Merged
merged 2 commits into from
Mar 9, 2022

Conversation

Envek
Copy link
Contributor

@Envek Envek commented Feb 28, 2022

Google recommends to use Incremental authorization and request scopes only when needed. And there is include_granted_scopes option to enable this mode. And it works nice!

However, now it is hard to figure out whether user already has been granted required scopes or not yet, because there is no information about it in the auth hash. In this pull request I'm trying to solve this problem.

Luckily, there is API for that: tokeninfo endpoint (however scope isn't documented here, but documented in NodeJS API, I found info about it here and in my experiments it always return list of granted scopes even if token was acquired without using include_granted_scopes). And more luckily, omniauth-google-oauth2 is already using it for token validation!

So I added spec for credentials section of Auth hash (there wasn't one) and added output scope there as it is present in tokeninfo output.

@Envek Envek force-pushed the return-available-scopes branch from fce344c to 02ffbcf Compare February 28, 2022 19:13
@zquestz
Copy link
Owner

zquestz commented Mar 9, 2022

Looks great, thanks for the contribution!

@zquestz zquestz merged commit 665a8cc into zquestz:master Mar 9, 2022
@Envek
Copy link
Contributor Author

Envek commented Mar 10, 2022

Thank you for merging!

It would be lovely if you release a new version with all the goodies accumulated since last release.

@zquestz
Copy link
Owner

zquestz commented Mar 11, 2022

Done. 1.0.1 is out. =)

@Envek Envek deleted the return-available-scopes branch March 11, 2022 08:16
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

Successfully merging this pull request may close these issues.

2 participants