Search code examples
google-admin-sdkgoogle-apps-marketplacegoogle-directory-api

With Google Apps Admin SDK Directory API, how can I get authenticated user id?


I have an authenticated user and am able to query for a list of domain users using the google apis php client library.

However, it is unclear to me how I can retrieve the currently logged in user's user id. I tried using the my_customer alias which works for the list method, but when I try to do the plain GET request with user key as my_customer, it of course fails.

I know this must be something quite simple, but I cannot for the life of me find an answer in the documentation, so I'm pretty much reduced to guessing at this point.


Solution

  • For your app to work as Google Apps marketplace app, you must implement authentication using OAUTH2.

    As a result you must have access to one of the following scopes which provide the APIs that get you the user Id :