I want to authorize non-admin users to use AdminDirectory (part of Google apps Admin SDK) as a part of a google apps script. Basically I want the users to get a list of other users' full names based on their user name.
I understand I can do this using OAuth2 but I cannot find examples of Google apps script-code for Admin SDK-AdminDirectory.
I have created a service account and have and have my Client ID and key ID. What do I need to do next? I found this https://developers.google.com/api-client-library/javascript/features/authentication but I can't figure out how to get the authorization to work.
Here is a minimal version of my script: (It will produce the full name of user [email protected] for authorized users)
function grupplistor() {
var userinfo = AdminDirectory.Users.get("[email protected]");
Logger.log ([userinfo.name.fullName]);
}
You can try using creating the service account and its credentials.
Source:
https://github.com/googlesamples/apps-script-oauth2
https://github.com/Spencer-Easton/Apps-Script-Drive-Service-Account-Library
Hope this helps