I'm building an Angular application that uses the Google API Client Library for JavaScript and it requires user permissions at login.
Permission to access Google Drive is required, but it is not checked when the consent screen is initially displayed.
So I need to know if the user has checked that checkbox on the consent screen to make sure the app works correctly.
How do I know that from the JavaScript code?
Asked
Active
Viewed 1,056 times
1

Inclu Cat
- 354
- 1
- 12
1 Answers
2
The response from the token endpoint (https://oauth2.googleapis.com/token
) contains a scope
field. This field tells you which scopes were actually granted:
{
"access_token": "ya29.A0...",
"expires_in": 3599,
"scope": "https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/userinfo.email openid",
"token_type": "Bearer",
"id_token": "ey..."
}

Johannes Passing
- 2,715
- 16
- 13
-
Thanks for the comment but I'm using Google API JavaScript Library and don't want to handle the raw data of the response if possible... I eventually found another solution ( rather, it was a mistake in my settings ) that kept the screen from showing the check boxes acorrding to this [answer](https://stackoverflow.com/a/61103955/14952561). – Inclu Cat Jan 21 '22 at 05:43
-
Sorry for the wrong information. It seems that showing the checkbox is something that [cannot be avoided.](https://stackoverflow.com/questions/64573910/disable-checkboxes-on-google-consent-screen/65128371#65128371) And I found [gapi.auth2.AuthResponse](https://developers.google.com/identity/sign-in/web/reference#gapiauth2authresponse) is the method that returns the response Johanness said above. I'll try this. Thanks. – Inclu Cat Jan 22 '22 at 05:45
-
Hey what's the equivalent in python to find this token? – Aysennoussi Sep 15 '22 at 18:11