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.
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 (howeverscope
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 usinginclude_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 outputscope
there as it is present intokeninfo
output.