You need to impersonate an admin:
Only accounts with User Management privileges (like a Super Admin, or a User Management Admin) can access Users: get. You have to take into account that this is part of Admin SDK, which is to be used by admin accounts.
You can also check this is not possible if you try calling this via
Try this API on the reference docs (you’ll get the same message:
Not Authorized to access this resource/api).
It doesn’t matter that you’re using a Service Account with domain-wide authority: when the service account is impersonating another user, it can only access the resources this user can access.
In this case, the impersonated account should have user management privileges if you want to retrieve user data from Admin SDK.
But since these privileges are not necessary for calling the Gmail API method, you could impersonate an admin account when calling
Users: get, and a regular one when calling users.settings.sendAs.update.
CLICK HERE to find out more related problems solutions.