Google compute engine 获取403“;许可不足“;从gmail api使用从gce实例获取默认应用程序

Google compute engine 获取403“;许可不足“;从gmail api使用从gce实例获取默认应用程序,google-compute-engine,gmail-api,Google Compute Engine,Gmail Api,我已经激活了gmail api,并且我在一个“完全访问所有Google云服务的api”的实例上。当我从实例运行以下操作时: credentials = GoogleCredentials.get_application_default() service = build('gmail', 'v1', credentials=credentials) service.users().messages().list(userId='me').execute() 我得到: HttpError: &l

我已经激活了gmail api,并且我在一个“完全访问所有Google云服务的api”的实例上。当我从实例运行以下操作时:

credentials = GoogleCredentials.get_application_default()
service = build('gmail', 'v1', credentials=credentials)
service.users().messages().list(userId='me').execute()
我得到:

HttpError: <HttpError 403 when requesting https://www.googleapis.com/gmail/v1/users/me/messages/send?alt=json returned "Insufficient Permission">
HttpError:

我已经尝试了其他几个gmail api调用,这始终是响应

您将需要使用方法。

您将需要使用方法。

处理文档:
来自oauth2client.gce import AppAssertionCredentials scope=https://www.googleapis.com/auth/gmail.compose'credentials=AppAssertionCredentials(作用域)http_auth=credentials.authorize(http())service=build('gmail','v1',http=http_auth)service.users().messages().list(userId='me').execute()
从oauth2client.gce import AppAssertionCredentials scope='name'获取相同的结果https://www.googleapis.com/auth/gmail.compose'凭据=AppAssertionCredentials(范围)http\u auth=credentials.authorize(http())service=build('gmail','v1',http=http\u auth)service.users().messages().list(userId='me').execute()获得相同的结果403