I am using text-to-speech API in a web app. Locally, I can download the JSON for my service account and then get a token from it, e.g., in R:
token <- gargle::credentials_service_account(
path = Sys.getenv("GL_AUTH"),
scopes = "https://www.googleapis.com/auth/cloud-platform"
)
where, GL_AUTH is an environment variable that contains the path to the JSON file. Then I can get access token with token$credentials$access_token. Now, if I deploy this app to Cloud Run with a github repo that contains my app code and text-to-speech API request, how do I get the access_token? GitHub won't allow me to put the JSON file in the repo.
Hi @durraniu,
Welcome to Google Cloud Community!
Storing your service account key JSON file directly in your GitHub repository is a significant security risk.
Here are several ways to securely manage your Google Cloud service account credentials in a Cloud Run deployment:
Remember to follow Google Cloud's best practices for security and IAM roles to minimize the risk of unauthorized access to your service account. Always use the least privilege principle – grant your service account only the permissions it absolutely needs.
I hope the above information is helpful.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |