Google app engine AccessTokenRefreshError:无效的\u作用域
我正试着用一个Cron.yaml做一些事情 我的cron工作正常,但是身份验证没有问题 在本地主机中,我使用以下命令:Google app engine AccessTokenRefreshError:无效的\u作用域,google-app-engine,cron,oauth-2.0,Google App Engine,Cron,Oauth 2.0,我正试着用一个Cron.yaml做一些事情 我的cron工作正常,但是身份验证没有问题 在本地主机中,我使用以下命令: from oauth2client.appengine import AppAssertionCredentials storage_credentials = AppAssertionCredentials(scope='https://www.googleapis.com/auth/storage') storage_http = storage_credenti
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:无效的\u作用域:
不是有效的作用域
有人能解释吗
编辑
同时,我用同样的方法去做,我没有问题 取自谷歌云存储认证,似乎您需要以下范围之一:
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:)取自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:)您使用的是谷歌云存储API吗?还是客户端库?@Patrice我使用客户端库很酷。总之,查看文档,似乎您没有使用正确的范围…但是为什么我可以将其与“AppAssertionCredentials”一起使用呢?这是stange no?您提到AppAssertionRedentials仅在本地devserver上工作,这与应用程序引擎不同,因此可能存在您的问题您是否使用Google云存储API?还是客户端库?@Patrice我使用客户端库很酷。总之,查看文档,似乎您没有使用正确的范围…但是为什么我可以将其与“AppAssertionCredentials”一起使用呢?这是stange no?您提到AppAssertionCredentials仅在本地devserver上工作,这与应用程序引擎不同,因此可能存在您的问题是的,我明白了!我在寻找“更新我的配置”。我假设它是完全控制的,因为只读似乎授予对数据的访问权,而不是元数据。我将使用完全控制,因为我需要删除一些文件。但我仍然有一个问题:“访问未配置。API(云存储API)未为您的项目启用。请使用Google开发者控制台更新您的配置。”您知道如何更新配置吗?通常,当您有后续问题时,您应该打开一个新问题,因为堆栈是Q和as的存储库,不是论坛。在任何情况下,我认为您需要转到“console.developers.google.com”,然后单击您的项目,然后单击API,然后启用“云存储API”,好的,谢谢您的帮助。“云存储API”已启用,问题仍然存在。是的,我看到了!我在寻找“更新我的配置”。我假设它是完全控制的,因为只读似乎授予对数据的访问权,而不是元数据。我将使用完全控制,因为我需要删除一些文件。但我仍然有一个问题:“访问未配置。API(云存储API)未为您的项目启用。请使用Google开发者控制台更新您的配置。”您知道如何更新配置吗?通常,当您有后续问题时,您应该打开一个新问题,因为堆栈是Q和as的存储库,不是论坛。在任何情况下,我认为您需要转到“console.developers.google.com”,然后单击您的项目,然后单击API,然后启用“云存储API”,好的,谢谢您的帮助。“云存储API”已启用,问题仍然存在。