Google云端存储HttpAccessTokenRefresh错误:invalid_grant:错误的请求

问题描述:

我在尝试连接到我的任何项目中的Google云端存储桶时(以前都在使用),我收到此错误oauth2client.client.HttpAccessTokenRefreshError: invalid_grant: Bad RequestGoogle云端存储HttpAccessTokenRefresh错误:invalid_grant:错误的请求

from gcloud import storage 
client = storage.Client() 
bucket = client.get_bucket(bucket_name) 

我在同事的笔记本电脑上通过命令行登录到我的gcloud帐户,并且该脚本连接到云端存储正常。我的同事然后在我的电脑上登录了他的gcloud帐户,但这对他也不起作用。我们认为这是服务器时间问题,许多其他帖子引用或我的电脑非常错误。

我们跑ntpdate并得到8 Nov 12:00:38 ntpdate[3468]: no servers can be used, exiting我们也用ntpd去过,但无济于事。

如果有任何建议,或者我做错了什么,请让我知道。另外如果你需要更多的细节来帮助我,请让我知道!

Project in:Python 2.7 | 操作系统:MacOS Sierra v 10.12.1 | Google云sdk:133.0.0

我的解决方案很愚蠢和令人沮丧,但我希望这可以帮助别人。

我已经检查了我与gcloud认证,并已撤销,并在使用这些命令

gcloud auth revokegcloud auth login然后按照后浮现在得到认证的步骤重新登录。 这些步骤不起作用。

然后我通过谷歌挖不那么友好的文档小时,回来到这个网页:https://googlecloudplatform.github.io/google-cloud-python/stable/google-cloud-auth.html

If you're developing locally, the easiest way to authenticate is using the Google Cloud SDK:

$ gcloud beta auth application-default login

Note that this command generates credentials for client libraries. To authenticate the CLI itself, use:

$ gcloud auth login

我还没有完成准备好这两个命令之间的区别是什么,但我的所有项目现在都可以工作获得。祝你好运

简称: 使用gcloud beta auth application-default login

+0

我昨天又遇到了这个问题,与同事和这个解决方案仍然有效,为2017年7月12日 –