Reputation: 11
I have a google marketplace app that has a service account with the following permissions: https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/admin.directory.group.readonly,https://www.googleapis.com/auth/admin.directory.orgunit.readonly,https://www.googleapis.com/auth/admin.directory.user.readonly
When a non-admin user authenticates into the app, the app needs to see that user's orgUnitPath in order to know where to place that user.
Specifying viewType=domain_public when doing a $directory->users->get call doesn't return the orgUnitPath, but when I specify viewType=admin_view I get an exception that the user doesn't have authorization to access this API.
Any ideas? Thanks
Upvotes: 0
Views: 666
Reputation: 12673
The orgUnitPath
field is not returned using the "domain_public" viewType
, as you've found. Instead, you'll need to use the viewType
"admin_view" (the default) and make the request as an admin. You can use the service account to impersonate an admin on the domain, as shown here.
Upvotes: 1