3
votes

I am following the docs here and it says:

The simplest way for applications to authenticate to a Google Cloud Platform API service is by using Application Default Credentials (ADC). Services using ADC first search for credentials within a GOOGLE_APPLICATION_CREDENTIALS environment variable; Google Cloud recommends you set this environment variable to point to your service account key file (the .json file downloaded when you created a service account key, as explained in Set Up a Service Account.

And it says to use this command:

$ export GOOGLE_APPLICATION_CREDENTIALS=<path_to_service_account_file>

In the Google Shell, I have attempted this:

<INSERT_SOMETHING>"~$ $ export GOOGLE_APPLICATION_CREDENTIALS=</Users/grantespanet/Downloads/myfile.json>

But I get this error: -bash: syntax error near unexpected token newline

I have also tried this:

<INSERT_SOMETHING>:~$ $ export GOOGLE_APPLICATION_CREDENTIALS=/Users/grantespanet/Downloads/myfile.json

but nothing happens

I know the command is pointing to the correct file location. How can I successfully Authenticate Application Default Credentials?

1
Are you performing any other command than "export"? Are you expecting export to do anything?Fred
I'm not sure honestly, I'm just trying to follow the docs to implement translations with The Google Translation API, but I used gcloud auth application-default login and that might have fixed my problem. @Fredgrantespo

1 Answers

2
votes

The command you are executing is a variable assignment. Variable GOOGLE_APPLICATION_CREDENTIALS is given the value that follows the = sign.

The export keyword has the effect of making this variable available to child processes of the shell you are executing it from. In plain terms, it means any program you launch from the shell will have a copy of that variable (with its value) and can use it.

It is entirely normal for that command to produce no visible result or output.

The instructions you have probably require you to launch other commands after this one, which will use this value. Try performing the next steps.