Courseiva
Setting Up a Cloud Solution EnvironmentmediumMultiple ChoiceObjective-mapped

Google ACE Setting Up a Cloud Solution Environment Practice Question

A developer needs to authenticate to Google Cloud from their local machine to run application code that reads from Cloud Storage. They use a service account. Which gcloud command should they use to obtain application credentials?

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

gcloud auth activate-service-account --key-file=KEY_FILE

The command 'gcloud auth application-default login' obtains user credentials for Application Default Credentials (ADC). For a service account, they would use 'gcloud auth activate-service-account' or set the GOOGLE_APPLICATION_CREDENTIALS environment variable.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • gcloud auth login

    Why it's wrong here

    The `gcloud auth login` command triggers an interactive OAuth flow that authenticates you as a Google user account, not as a service account. It stores user credentials in the gcloud config directory and is intended for human users accessing Cloud Console or gcloud with their own identity. It cannot use a service account's JSON key file, so it is fundamentally the wrong tool for authenticating as a service account.

  • gcloud config set account service-account@project.iam.gserviceaccount.com

    Why it's wrong here

    The `gcloud config set account` command merely changes the active account property in your gcloud configuration to point to an already-authenticated identity. It does not perform any authentication handshake or validate credentials; it only tells gcloud which existing credential set to use in subsequent commands. If the service account has not been previously authenticated via `activate-service-account`, this command will not establish any credentials and will lead to authentication failures.

  • gcloud auth application-default login

    Why it's wrong here

    The `gcloud auth application-default login` command creates User Application Default Credentials (ADC) that are used by Google Cloud client libraries to discover credentials, not by gcloud itself. It authenticates with a human user's account, typically via a browser OAuth flow, and stores credentials for ADC, not for a service account. To authenticate as a service account for ADC, you would set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable or use an attached service account—not this command.

  • gcloud auth activate-service-account --key-file=KEY_FILE

    Why this is correct

    The command `gcloud auth activate-service-account --key-file=KEY_FILE` is the correct way to authenticate gcloud with a service account using its private key JSON file. It reads the key file, derives the service account email, and establishes that identity as the active authenticated account for gcloud CLI operations. This command both authenticates and activates the service account in one step, enabling subsequent gcloud commands to inherit that identity.

About these practice questions

One of 769 original ACE practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This ACE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the ACE exam.