0
votes

I am writing an automation CLI script code that is reading G Suite user aliases and their Gmail send-as settings. This script cannot have user interaction.

I setup everything with super-admin user account. Setup a service account with the super-admin user and set domain-wide delegation on. And I can list users in domain using Admin SDK API, and I can get Gmail settings of the super-admin user. But if I try to read Gmail settings of other plain user in my domain, it fails with this error.

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "forbidden",
    "message": "Delegation denied for [email protected]"
   }
  ],
  "code": 403,
  "message": "Delegation denied for [email protected]"
 }
}

It it allowed to read other users in same G Suite domain email settings using Gmail API? Or is it just always prohibited? What should I do to read their email settings?

1

1 Answers

0
votes

You're trying to access the settings from other users with your super-admin delegated credentials which doesn't have that kind of access. You can't retrieve other users settings with your super-admin credentials.

You need to generate delegated credentials for each user and use those credentials to retrieve the settings information of each one.