- 1 year ago
How to declare the `GOOGLE_APPLICATION_CREDENTIALS` environment variable?
To declare the GOOGLE_APPLICATION_CREDENTIALS
environment variable, you need to set it to the path of your Google Cloud service account key file. This environment variable is used by Google Cloud client libraries to locate the service account key file and authenticate your application.
Here's how you can declare the GOOGLE_APPLICATION_CREDENTIALS
environment variable in different environments:
Windows (Command Prompt):
vbnetset GOOGLE_APPLICATION_CREDENTIALS=path\to\your\service-account-key.json
Note: Replace
path\to\your\service-account-key.json
with the actual file path to your service account key JSON file.To verify that the environment variable is set correctly, you can use the
echo
command:bashecho %GOOGLE_APPLICATION_CREDENTIALS%
Windows (PowerShell):
ruby$env:GOOGLE_APPLICATION_CREDENTIALS="path\to\your\service-account-key.json"
To verify the environment variable:
ruby$env:GOOGLE_APPLICATION_CREDENTIALS
Linux / macOS (Bash):
javascriptexport GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/service-account-key.json
To verify the environment variable:
bashecho $GOOGLE_APPLICATION_CREDENTIALS
Remember to replace /path/to/your/service-account-key.json
with the actual file path to your service account key JSON file.
After setting the GOOGLE_APPLICATION_CREDENTIALS
environment variable, you can use Google Cloud client libraries in your application to authenticate and access Google Cloud services using the specified service account credentials.