简体   繁体   English

python google-cloud-storage库未选择活动的用户帐户

[英]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.

相关问题 Google-cloud-storage中是否有与Python相对应的`refFromUrl`吗? - Is there an equivalent to `refFromUrl` in google-cloud-storage for Python? 使用 google-cloud-storage Python 客户端获取下载标头? - Get download headers with google-cloud-storage Python client? 得到了一个意外的关键字参数“超时”(Python 中的 google-cloud-storage) - Got an unexpected keyword argument 'timeout' (google-cloud-storage in Python) 使用 Workload Identity Federation 对 Python 中的 Google-Cloud-Storage 进行身份验证 - Authenticate Google-Cloud-Storage in Python using Workload Identity Federation Django 2:使用 google-cloud-storage 将媒体上传到 Google Cloud Storage - Django 2: upload media to Google Cloud Storage with google-cloud-storage 如何将超时和重试装饰器功能应用于 python 中的 google-cloud-storage 客户端? - How do I apply timeout and retry decorator functions to google-cloud-storage client in python? 使用google-cloud-storage将数据从gcs传输到s3 - Transfering data from gcs to s3 with google-cloud-storage PATCH 中的 google-cloud-storage 随机 503 错误 - google-cloud-storage random 503 error in PATCH google-app-engine标准中的google-cloud-storage权限被拒绝 - google-cloud-storage permission denied in google-app-engine standard 云存储:如何为python boto库设置服务帐户凭据 - Cloud Storage: how to setup service account credentials for python boto library
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM