AccessTokenRefreshError: invalid_scope

AccessTokenRefreshError: invalid_scope

我正在尝试用 Cron.yaml 做一些事情 我的 cron 工作正常,但身份验证号。

在我使用的本地主机中:

from oauth2client.appengine import AppAssertionCredentials

    storage_credentials = AppAssertionCredentials(scope='https://www.googleapis.com/auth/storage')
storage_http = storage_credentials.authorize(httplib2.Http())
storage_service = build("storage", "v1", http=storage_http)

这很好用,但是当我在 GAE 中部署它时,它不起作用。

我找到了一个解决方案:

from oauth2client.client import SignedJwtAssertionCredentials

storage_credentials = SignedJwtAssertionCredentials(
  "463239370591-kvr7qpa2k5ee5jgdjgmk9ohc3ao3gve5@developer.gserviceaccount.com", key,
  scope=("https://www.googleapis.com/auth/storage")
)
storage_http = storage_credentials.authorize(httplib2.Http())
storage_service = build("storage", "v1", http=storage_http)

使用这段代码我有一个错误:

AccessTokenRefreshError: invalid_scope: https://www.googleapis.com/auth/storage is not valid scope.

有人能解释一下吗?

编辑

同时我用同样的方法https://www.googleapis.com/auth/bigquery没有问题!

摘自 docs 关于 Google 云存储身份验证,您似乎需要以下范围之一:

https://www.googleapis.com/auth/devstorage.read_only

https://www.googleapis.com/auth/devstorage.read_write

https://www.googleapis.com/auth/devstorage.full_control

取决于你想做什么。您需要确保在您的控制台中启用了 API,并且还要使用云存储 JSON API :)