使用boto和gcs-oauth2-boto-plugin时,Google Cloud Storage auth失败

时间:2014-09-26 22:32:37

标签: oauth-2.0 boto google-cloud-platform

我正在关注使用boto访问Google云存储的this教程。我创建了一个服务帐户,下载了p12文件,并使用" gsutil config -e"生成了.boto配置文件。命令。但是,当我尝试在我的Google云端存储中列出存储桶时,出现以下错误。

import boto
import gcs_oauth2_boto_plugin
uri = boto.storage_uri('', 'gs')
for b in uri.get_all_buckets():
...     print b.name
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/deployer/ENV/local/lib/python2.7/site-packages/boto/storage_uri.py", line 571, in get_all_buckets
    return conn.get_all_buckets(headers)
  File "/home/deployer/ENV/local/lib/python2.7/site-packages/boto/s3/connection.py", line 436, in get_all_buckets
    response = self.make_request('GET', headers=headers)
  File "/home/deployer/ENV/local/lib/python2.7/site-packages/boto/s3/connection.py", line 664, in make_request
    retry_handler=retry_handler
  File "/home/deployer/ENV/local/lib/python2.7/site-packages/boto/connection.py", line 1053, in make_request
    retry_handler=retry_handler)
  File "/home/deployer/ENV/local/lib/python2.7/site-packages/boto/connection.py", line 911, in _mexe
    request.authorize(connection=self)
  File "/home/deployer/ENV/local/lib/python2.7/site-packages/boto/connection.py", line 375, in authorize
    connection._auth_handler.add_auth(self, **kwargs)
  File "/home/deployer/ENV/local/lib/python2.7/site-packages/gcs_oauth2_boto_plugin/oauth2_plugin.py", line 70, in add_auth
    self.oauth2_client.GetAuthorizationHeader()
  File "/home/deployer/ENV/local/lib/python2.7/site-packages/gcs_oauth2_boto_plugin/oauth2_client.py", line 347, in GetAuthorizationHeader
    return 'Bearer %s' % self.GetAccessToken().token
  File "/home/deployer/ENV/local/lib/python2.7/site-packages/gcs_oauth2_boto_plugin/oauth2_client.py", line 318, in GetAccessToken
    access_token = self.FetchAccessToken()
  File "/home/deployer/ENV/local/lib/python2.7/site-packages/gcs_oauth2_boto_plugin/oauth2_client.py", line 395, in FetchAccessToken
    credentials.refresh(http)
  File "/home/deployer/ENV/local/lib/python2.7/site-packages/oauth2client/client.py", line 516, in refresh
    self._refresh(http.request)
  File "/home/deployer/ENV/local/lib/python2.7/site-packages/oauth2client/client.py", line 653, in _refresh
    self._do_refresh_request(http_request)
  File "/home/deployer/ENV/local/lib/python2.7/site-packages/oauth2client/client.py", line 710, in _do_refresh_request
    raise AccessTokenRefreshError(error_msg)
oauth2client.client.AccessTokenRefreshError: invalid_grant

0 个答案:

没有答案