Skip to content
agentgateway has joined the Agentic AI FoundationLearn more

For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.

GCP backend authentication

Page as Markdown

Authenticate to a Google Cloud service from the gateway with a Google-issued token.

Verified Code examples on this page have been automatically tested and verified.

Attaches to:

Configuration examples

To connect to a Google Cloud service, use gcp. Agentgateway reads Application Default Credentials from the environment and attaches a token to each request.

Each example shows the backendAuth policy only. Attach it to a backend under backends[].policies, or to a route under routes[].policies.

backendAuth:
  gcp: {}

Set the type field to choose the kind of token. Most Google services take an access token, and Cloud Run takes an ID token.

backendAuth:
  gcp:
    type: accessToken
backendAuth:
  gcp:
    type: idToken
    audience: "https://my-cloudrun-service-xyz.run.app"

Important

The token type is camelCase in the standalone binary: accessToken and idToken. The Kubernetes custom resources spell the same values in PascalCase, as AccessToken and IdToken. Agentgateway rejects the PascalCase spelling rather than falling back to a default.

Review the following table to understand this configuration.
FieldDescription
typeKind of token to fetch: accessToken for most Google services, or idToken for Cloud Run. Omit the field and agentgateway fetches an access token.
audienceThe aud claim of the ID token. Valid only with idToken. Omit the field and agentgateway uses the hostname of the backend.
credentialADC-compatible Google credential JSON, either inline or as {file: <path>}. Omit the field to use the ambient credentials of the environment.

By default, agentgateway resolves credentials from the environment. It reads the path in the GOOGLE_APPLICATION_CREDENTIALS environment variable, and falls back to $HOME/.config/gcloud/application_default_credentials.json. On Windows the fallback path is %APPDATA%/gcloud/application_default_credentials.json. Set the credential field to supply the credential JSON directly instead.

Not every credential type works with both token types.

Credential JSON typeaccessTokenidToken
authorized_userYesYes
service_accountYesYes
impersonated_service_accountYesYes
external_accountYesNo
gdch_service_accountNoYes, and audience is required

Note

Agentgateway parses the credential JSON when it loads the configuration, not on the first request. A malformed or incomplete credential therefore fails --validate-only, which is where you want to find out about it.

Was this page helpful?
Agentgateway assistant

Ask me anything about agentgateway configuration, features, or usage.

Note: AI-generated content might contain errors; please verify and test all returned information.

Tip: one topic per conversation gives the best results. Use the + button in the chat header to start a new conversation.

Switching topics? Starting a new conversation improves accuracy.
↑↓ navigate select esc dismiss

What could be improved?

Your feedback helps us improve assistant answers and identify docs gaps we should fix.

Need more help? Join us on Discord: https://discord.gg/y9efgEmppm

Want to use your own agent? Add the Solo MCP server to query our docs directly. Get started here: https://search.solo.io/.