gmail api - domain wide delegation

472 Views Asked by At

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 [email protected]"

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 = '[email protected]'
    service = get_auth()
    response = service.users().messages().list(userId=user).execute()

Thanks!

0

There are 0 best solutions below