第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Google cloud get bucket - 適用于 cli 但不適用于 python

Google cloud get bucket - 適用于 cli 但不適用于 python

犯罪嫌疑人X 2022-12-27 15:31:11
我被要求與外部谷歌存儲桶進行集成,我收到了一個憑據(jù) json,在嘗試這樣做時 gsutil ls gs://bucket_name(在使用 creds json 配置自己之后)我收到了有效的響應,以及當我嘗試將文件上傳到存儲桶中時。嘗試使用 Python3 執(zhí)行此操作時,它不起作用:在使用google-cloud-storage==1.16.0(也嘗試過較新的版本)時,我正在做:project_id = credentials_dict.get("project_id")credentials = service_account.Credentials.from_service_account_info(credentials_dict)client = storage.Client(credentials=credentials, project=project_id)bucket = client.get_bucket(bucket_name)但是get_bucket在線上,我得到:google.api_core.exceptions.Forbidden: 403 GET https://www.googleapis.com/storage/v1/b/BUCKET_NAME?projection=noAcl: USERNAME@PROJECT_ID.iam.gserviceaccount.com does not have storage.buckets.get access to the Google Cloud Storage bucket.與我集成的外部合作伙伴說用戶設置正確,并證明他們表明我可以使用gsutil.你能幫忙嗎?知道可能是什么問題嗎?
查看完整描述

2 回答

?
ibeautiful

TA貢獻1993條經(jīng)驗 獲得超6個贊

答案是信譽確實是錯誤的,但是當我嘗試在客戶端client.bucket(bucket_name)而不是client.get_bucket(bucket_name).



查看完整回答
反對 回復 2022-12-27
?
蕭十郎

TA貢獻1815條經(jīng)驗 獲得超13個贊

請按照以下步驟正確設置適用于 Python 的 Cloud Storage 客戶端庫。通常,云存儲庫可以使用應用程序默認憑據(jù)或環(huán)境變量進行身份驗證。


請注意,推薦使用的方法是使用環(huán)境變量設置身份驗證(即,如果您使用的是 Linux:export GOOGLE_APPLICATION_CREDENTIALS="/path/to/[service-account-credentials].json"應該可行)并完全避免使用該service_account.Credentials.from_service_account_info()方法:


from google.cloud import storage


storage_client = storage.Client(project='project-id-where-the-bucket-is')

bucket_name = "your-bucket"

bucket = client.get_bucket(bucket_name)

應該可以簡單地工作,因為身份驗證是由客戶端庫通過環(huán)境變量處理的。


現(xiàn)在,如果您有興趣顯式使用服務帳戶而不是使用service_account.Credentials.from_service_account_info()方法,您可以通過from_service_account_json()以下方式直接使用該方法:


from google.cloud import storage


# Explicitly use service account credentials by specifying the private key

# file.

storage_client = storage.Client.from_service_account_json(

    '/[service-account-credentials].json')

bucket_name = "your-bucket"

bucket = client.get_bucket(bucket_name)

在此處查找有關如何向您的應用程序提供憑據(jù)的所有相關詳細信息。



查看完整回答
反對 回復 2022-12-27
  • 2 回答
  • 0 關注
  • 110 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號