[英]python google-cloud-storage library does not pick active user-account
I am using this tutorial to connect my GCS. 我正在使用本教程来连接我的GCS。 I have multiple account with google and activated one with
gcloud auth login
and I double checked with gcloud auth list
and it shows both accounts but one I need is marked with ACTIVE
. 我有多个google帐户,并用
gcloud auth login
激活了一个帐户,并用gcloud auth list
检查了该帐户,它显示了两个帐户,但我需要的一个帐户已标记为ACTIVE
。 But when I try to run the code mentioned in tutorial, getting following error 但是当我尝试运行教程中提到的代码时,出现以下错误
google.api_core.exceptions.Forbidden: 403 GET https://www.googleapis.com/storage/v1/b?project=<myproject>&projection=noAcl: <INACTIVE USER ACCOUNT> does not have storage.buckets.list access to project <PROJECT-ID>.
I don't know why it is picking up inactive account instead of active account. 我不知道为什么它会选择非活动帐户而不是活动帐户。 am I missing something here?
我在这里想念什么吗? Please help
请帮忙
Even I revoked inactive account using command gcloud auth revoke --account
, still python scripts referring that account only and throwing the same error. 即使我使用
gcloud auth revoke --account
命令撤消了非活动帐户,仍然是仅引用该帐户并抛出相同错误的python脚本。
PS - I am using Anaconda3. PS-我正在使用Anaconda3。
I too had the same issue, It got resolved by exporting env variable GOOGLE_APPLICATION_CREDENTIALS
with a value pointing to the path of your bucket credentials JSON file eg. 我也遇到了同样的问题,通过导出环境变量
GOOGLE_APPLICATION_CREDENTIALS
解决,该变量的值指向存储桶凭据JSON文件的路径,例如。
export GOOGLE_APPLICATION_CREDENTIALS=/Users/myuser/Downloads/googleCredentials.json
This command basically sets default account credentials. 此命令基本上设置默认帐户凭据。 This Hope it helps you too.
希望它也对您有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.