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