G Suite Martkeplace: Get user who granted domain wide delegation to an app

Viewed 115

Assume we have an app on G Suite Marketplace, and a G Suite domain administrator wants to delegate domain-wide access to the domain's users' data (as explained here).

For signup purposes, the 3rd service itself needs to know the domain name and the username of the administrator who performed domain-wide delegation of authority. This is needed to be able to use the Directory API (see note here)

I can easily get the domain name (by using Universal Navigation Extension, and adding ${DOMAIN_NAME} to the callback URL, as explained here). However, I didn't find a way to programmatically access the username of the administrator who performed DWD.

Any hints how to do that? Or if that is possible at all?

Thanks in advance!

1 Answers

Method 1:

When the user clicks in the launcher link (or just during installation with the configuration link you can configure) you need to do the OAuth2 flow and obtain the user email. Then you use the email assuming it is from an admin and it usually should be. If not, just return an error and wait for the admin login.

Method 2: ONLY TO GET THE DOMAIN, not the user.

Use the Marketplace License API https://developers.google.com/gsuite/marketplace/v2/reference

You can periodically use the list endpoint and find the user that installs (or removes) your application.

In any case you should store the list of domain super admins to be used when necessary.

Related