我一直收到上述错误,我不知道如何解决这个问题。 我已启用域范围授权,并且还在“管理API访问”
中授权了Client-Id"""
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
有人有这个工作吗?如果是这样,请指出我收到错误的原因。