Oauth 2.0 使用boto和gcs-oauth2-boto-plugin时Google云存储验证失败

Oauth 2.0 使用boto和gcs-oauth2-boto-plugin时Google云存储验证失败,oauth-2.0,boto,google-cloud-platform,Oauth 2.0,Boto,Google Cloud Platform,下面是关于使用boto访问google云存储的教程。我创建了一个服务帐户,下载了p12文件,并使用gsutil config-e命令生成了.boto配置文件。然而,当我试图列出我的谷歌云存储中的存储桶时,我得到了以下错误 import boto import gcs_oauth2_boto_plugin uri = boto.storage_uri('', 'gs') for b in uri.get_all_buckets(): ... print b.name ... Traceb

下面是关于使用boto访问google云存储的教程。我创建了一个服务帐户,下载了p12文件,并使用gsutil config-e命令生成了.boto配置文件。然而,当我试图列出我的谷歌云存储中的存储桶时,我得到了以下错误

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

我也有同样的问题。你能解决它吗?我确实解决了,但我不记得我是怎么解决的。但与.boto文件有关。我想我要么生成了一组新的gs_访问密钥id和gs_机密密钥,要么重新配置了gcloud。