Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Directory user list from an app

I am creating an iOS app for internal use. We have a Google Domain. As part of the functionality of the app, I want to be able to search for all users in that domain. This can already be done in Gmail, the Apple Mail app, and others.

I found that you can use the Admin SDK for users.list to do exactly what I want to do. I created a Client ID for the iOS app and authorized my app to perform users.list.

Permissions in developer console

However, now I get a permissions error for users who sign in with OAuth2:

OAuth authorized user not authorized to list users

I found that you can create a service account to make API requests on your behalf if you delegate it to have the authority. I'm not sure if this is what I want to do since this seems more like something for a secure server to do rather than an app. I'm also not sure how this integrates with a user (from our domain) who signs in with OAuth being able to list our users.

Is it possible to list/search the users in a Google domain purely through OAuth / frontend app?

like image 343
Explosion Pills Avatar asked Nov 08 '22 10:11

Explosion Pills


1 Answers

Aside from caching your own list, I think there are two ways to give users the ability to list all users:

A. Undocumented call to this GAL API: https://www.google.com/m8/feeds/gal/your-domain-goes-here/full?alt=json (source). You can test this in the Google OAuth Playground by selecting the scope for the Contacts V3 API or using the string https://www.google.com/m8/feeds/.

B. In the Admin console, create an "all users" group. Assign to a newly created Admin Role. Grant the admin role "read" in Privileges > Admin API Privileges > Users > Read (checked).

like image 51
Pete Avatar answered Nov 15 '22 11:11

Pete