I've created a project in GCP in which I'm trying to monitor inboxes of two accounts. I've created a service account with domain-wide delegation enabled via Google Admin Console. But I'm not able to access the inbox of these two accounts. I tried getting profile info:
def authenticate_gmail_api(): """Authenticates and returns the Gmail API service.""" creds = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES, subject=USER_EMAIL) return build('gmail', 'v1', credentials=creds) service = authenticate_gmail_api() profile = service.users().getProfile(userId='me').execute() print(profile) and it is printing this: {'emailAddress': '[email protected]', 'messagesTotal': 1375, 'threadsTotal': 405, 'historyId': '252086'}
But when I try to access the history details by calling history list:
history_response = service.users().history().list( userId='me', startHistoryId=start_history_id ).execute() print("History Response:", history_response) I'm using an old history ID and it gives only historyId like this: History Response: {'historyId': '252155'}
I've tested by accessing other accounts in the workspace and I'm able to get the history details. But not working for those two accounts I need to monitor. So I asked my Google admin to check account type. It seems it is a primary account (regular account listed under Users) but it has routing enabled to forward the messages to other email addresses. It's like support email addresses that businesses have and it goes to multiple people but also maintains a
How can I access this type of account via service account?