Java: How to set GOOGLE_APPLICATION_CREDENTIALS on Mac Sierra

Viewed 9983

I read documentation here and tried to use Terminal export GOOGLE_APPLICATION_CREDENTIALS=/path/to/json/file.json But when I open new terminal and type: echo $GOOGLE_APPLICATION_CREDENTIALS it doesn't display the path that I set. The program always says: The Application Default Credentials are not available. Do you have any idea why export command doesn't work ?

3 Answers

I solved using the terminal command

gcloud auth application-default login
export GOOGLE_APPLICATION_CREDENTIALS="/Users/_____/OneDrive/fdsafsdf.json"

In case you don't want to modify the .bash_profile, you can create a text file such as an export.txt with the above, and run the following before the execution of your code.

source export.txt
Related