【发布时间】:2022-10-02 00:28:18
【问题描述】:
我有一个带有专用服务帐户的 Cloud Run 实例(我在 UI(GCP Concole)-> 修订/安全选项卡中看到它)。我认为这意味着,它被设置为主要(默认)标识符。
在 Cloud Run 中,我运行一个 python 应用程序,我想生成一个签名的 url
credentials, project_id = google.auth.default()
blob = bucket.get_blob(blob_name)
expires = datetime.now() + timedelta(seconds=86400)
url = blob.generate_signed_url(expiration=expires, credentials=credentials)
但我收到以下错误消息(引用默认计算引擎服务帐户):
AttributeError: you need a private key to sign credentials.the credentials you are currently using <class \'google.auth.compute_engine.credentials.Credentials\'> just contains a token.
我的问题:
- 为什么默认服务帐户仍然是计算引擎一而不是专用服务帐户?
- 如何将我的专用服务帐户设置为 Cloud Run 实例的“默认/主”服务帐户?
标签: python google-cloud-platform google-cloud-run service-accounts