I keep getting the above error and I am not sure how to solve this. I have enabled Domain wide Delegation and also authorized the Client-Id in 'Manage API Access'
My Code looks like this:
"""
Sample program
"""
import googleapiclient.discovery
import json
import googleapiclient.errors
from google.oauth2 import service_account
SERVICE_ACCOUNT_FILE = 'abcd.json'
credentials = service_account.Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE)
scoped_credentials =
credentials.with_scopes(['https://mail.google.com/'])
delegated_credentials = credentials.with_subject('abcd')
service = googleapiclient.discovery.build('gmail','v1',credentials = delegated_credentials)
try:
results = service.users().labels().list(userId='abcd').execute()
except Exception as err:
print err
Has anyone got this working ? If so please point out why I am getting the error.