Gmail API restrict access to only one Group

374 Views Asked by At

I'm trying to find a way to read inbox email of a Google private Group using GmailAPI. I thought about using a service account that will be a member of this group with only read access. Do you know how can I do that?

Thanks,

Dan

1

There are 1 best solutions below

1
On

You need to set up domain wide delegation from a gsuite domain in order to use service accounts with gmail.

  • Open the Service accounts page. If prompted, select a project.
  • Click add Create Service Account, enter a name and description for the service account. You can use the default service account ID, or choose a different, unique one. When done click Create.
  • The Service account permissions (optional) section that follows is not required. - Click Continue. On the Grant users access to this service account screen, scroll down to the - Create key section. Click add Create key.
  • In the side panel that appears, select the format for your key: JSON is recommended.
  • Click Create. Your new public/private key pair is generated and downloaded to your machine; it serves as the only copy of this key. For information on how to store it securely, see Managing service account keys.
  • Click Close on the Private key saved to your computer dialog, then click Done to return to the table of your service accounts.

Perform Google Workspace Domain-Wide Delegation of Authority