# /google-cloud-recipe-auth: Choose the right Google Cloud credentials for each situation

Source: https://trendhub.net/skills/google-skills/google-cloud-recipe-auth
Skill folder: https://github.com/google/skills/tree/main/plugins/cloud/google-cloud-developer/skills/google-cloud-recipe-auth
Pack: Google Agent Skills (https://trendhub.net/skills/google-skills)
Works with: Any agent supported by the skills CLI, Claude Code (plugins), Codex (plugins), Antigravity CLI

This skill is a decision guide for authentication and authorisation on Google Cloud. It has the agent first establish who is calling, where the code runs and what it calls, then steer toward ADC and impersonation for local work, attached service accounts in production, Workload Identity Federation outside Google Cloud, and predefined IAM roles before custom ones.

## When to use it

- Your local code cannot reach a Google Cloud API and you are unsure which login to use.
- You are deploying to Cloud Run or Compute Engine and want to avoid service account key files.
- Code running on AWS, Azure or on premises needs to call Google Cloud.

## How it works

1. **Ask the four questions**: The agent clarifies who or what is authenticating, where it runs, what it targets, and whether a client library is in use.
2. **Separate CLI and ADC**: It explains that gcloud auth login signs in the CLI while application-default login creates the credentials client libraries pick up.
3. **Prefer keyless identities**: It recommends impersonation for developers and attached custom service accounts for workloads instead of downloaded keys.
4. **Grant least privilege**: It binds a predefined role on the specific resource and checks legacy access scopes when an attached account still fails.
5. **Run the checklist**: It reviews local versus production use, default service accounts, cross-cloud callers, OIDC for custom apps and API key restrictions.

## What it steers the agent away from

- Downloading service account JSON keys for local development.
- Running production workloads on the Compute Engine default service account.
- Leaving API keys unrestricted or stored in code.

## What it can touch

It mostly advises; any commands it suggests, such as application-default login or IAM bindings, change your local credentials or project policy only when you run them.

## Pairs well with

- `/gcloud`
- `/google-cloud-recipe-onboarding`
- `/cloud-run-basics`

## Questions

### How does a private Cloud Run service get called by another service?

The caller obtains a Google-signed OIDC ID token and sends it as a bearer token in the Authorization header.

### Where does ADC look for credentials?

It checks the GOOGLE_APPLICATION_CREDENTIALS variable, then the local gcloud credentials file, then the metadata server of an attached service account.
