grantespo
grantespo

Reputation: 2269

Unable to Authenticate Application Default Credentials

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?

Upvotes: 3

Views: 15727

Answers (2)

momo668
momo668

Reputation: 443

To make it clear, the following amendment to my original command works as provided by @Fred in the comment:

gcloud auth activate-service-account <account_email_id> --key-file=<key.json file>

Upvotes: 0

Fred
Fred

Reputation: 6995

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.

Upvotes: 2

Related Questions