TL;DR: Does Auth0’s google enterprise connection’s Enable Users API
checkbox grant access to the Google Admin Users API — and if so why is my setup not attaching the right scopes to the google access token?
I’m working on setting up a google enterprise connection for my Auth0 app using these docs:
The connection in auth0 is working. I can also retrieve the Google access token for my generated auth0 user’s connections
array and use it to access my generic user data within google.
However, as part of my flow I need to retrieve some of the google user’s custom attributes, which requires access to the Google Admin Directory/Users API, specifically the users.get endpoint.
So I stumbled upon this checkbox in the enterprise connection settings:
I assumed this would add the https://www.googleapis.com/auth/admin.directory.user
scope to the authorization request, which would in turn grant access to the google users API (aka the one at https://admin.googleapis.com/admin/directory/v1/users/...
— this is the only “users” API I know of in Google).
But when using the generated access token from my auth0 connections
array to hit the /admin/directory/v1/users/{userID}
endpoint, I get a 403:
{
"error": {
"code": 403,
"message": "Request had insufficient authentication scopes.",
"errors": [
{
"message": "Insufficient Permission",
"domain": "global",
"reason": "insufficientPermissions"
}
],
"status": "PERMISSION_DENIED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "ACCESS_TOKEN_SCOPE_INSUFFICIENT",
"domain": "googleapis.com",
"metadata": {
"method": "ccc.hosted.frontend.directory.v1.DirectoryUsers.Get",
"service": "admin.googleapis.com"
}
}
]
}
}
When using Google’s /tokeninfo
endpoint (https://oauth2.googleapis.com/tokeninfo?access_token=...
) I do see that the generated token only has these scopes, so the 403 isn’t unexpected.
"scope": "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile openid"
But(!) the checkbox in the Auth0 connections ettings clearly states that it needs access to the Google Admin SDK, which leads me to believe it is intended to grant access to the users API I’m trying to access.
Any ideas what’s off in my config? Or is it that the tokens associated with a user aren’t the tokens that can access the google admin API?