Different Authentication ways for GCP cloud

What to use and when

Table of contents

No heading

No headings in the article.

There are two ways to authenticate the user/service account

How to activate application default credentials:

  • Use your user account
gcloud auth application-default login
  • Use a service account(for any automation script/process)

    • set environment variable
GOOGLE_APPLICATION_CREDENTIALS=path/to/your/service_accont_key_file.json

You can also copy the above JSON file - path/to/your/service_accont_key_file.json into ~/.config/gcloud/application_default_credentials.json

On Windows, this might be different, from knowing the path to your config directory.

gcloud info --format="value(config.paths.global_config_dir)"

After all, this following command will give you the access token which can be used for authentication.

gcloud auth application-default print-access-token