我正在尝试用Cron.yaml做一些事情 我的cron工作正常,但身份验证号码
在localhost中我使用:
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无效范围。
有人可以解释一下吗?
修改
与此同时,我以同样的方式使用https://www.googleapis.com/auth/bigquery并且我没有遇到任何问题!
答案 0 :(得分:4)
从Google Cloud Storage身份验证的docs开始,您似乎需要其中一个范围:
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,并使用Cloud Storage JSON API:)