3

I am trying to get emails of all users of specific domain. I am able to get emails of user who created the service account (admin account), but during getting emails of other users of that domain I am facing HttpError 403 "Delegation denied for xxx@example.com"

I did the following steps:

Here is example code of my request to get emails data of other users (using python):

from googleapiclient.discovery import build
from oauth2client import file
from httplib2 import Http

TOKEN_FILEPATH = "/path-to-token-file/"

def get_auth():
    store = file.Storage(TOKEN_FILEPATH)
    creds = store.get()
    service = build('gmail', 'v1', http=creds.authorize(Http()))
    return service


def get_emails():
    user = 'xxx@example.com'
    service = get_auth()
    response = service.users().messages().list(userId=user).execute()

Thanks!

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
Harpreet Gill
  • 138
  • 2
  • 10
  • Are you sure that this thing is possible? – Matteo Bianchi Jan 25 '21 at 12:10
  • Have you checked that the credentials are able to impersonate the user? Check: [Preparing to make an authorized API call](https://developers.google.com/identity/protocols/oauth2/service-account#authorizingrequests) – Kessy Jan 25 '21 at 15:35

0 Answers0