admin管理员组文章数量:1332881
Keep getting "An error occurred: you need a private key to sign credentials.the credentials you are currently using <class 'google.authpute_engine.credentials.Credentials'> just contains a token"
I'm Trying to get Presigned URL so that it can be downloaded by app(for user profile) It works fine in my local since I have key path to the service account json key.
In cloud run I've tried secret manager but it didn't work, since instead of file it shows the value of the key itself.
bucket_name = os.environ.get("BUCKET_NAME")
service_account = os.environ.get("SERVICE_ACCOUNT")
credentials = compute_engine.Credentials()
project_id = os.environ.get("PROJECT_ID")
def get_bucket(bucket_name):
client = storage.Client(credentials=credentials, project=project_id)
bucket = client.get_bucket(bucket_name)
return bucket
def generate_presigned_url_for_profile(blob_name, expiration=3600):
storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(f"userProfile/{blob_name}")
url = blob.generate_signed_url(version="v4", expiration=datetime.timedelta(seconds=expiration), method='GET', service_account_email=service_account)
return url
I've tried using compute.engine.Credentials() and it didn't work
版权声明:本文标题:google cloud platform - How to get access to service account private key for PreSigned URLS? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742316911a2451997.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论