Skip to content

Token acquisition

Obtaining a provider token happens outside Xratu. This page is what you run to get one, and the properties it must have for the exchange to accept it.

The one rule

You arrive already authenticated with your identity provider. Be signed in to that provider in the same terminal or environment where you run the exchange. The exchange consumes a token you already hold.

What the token must carry

Property Requirement
Audience xratu-control-plane
Issuer One the control plane accepts for that provider
Subject or email Present, since the actor is derived from them

The audience is the same for every provider. Issuer acceptance differs per provider, and is covered in Supported identity providers.

GCP

TOKEN="$(gcloud auth print-identity-token \
  --impersonate-service-account=<service-account-email> \
  --audiences=xratu-control-plane)"

Minting an identity token with an audience requires a service-account identity or service-account impersonation. A plain user credential cannot do it, and this is the single most common reason a GCP exchange fails.

Azure

TOKEN="$(az account get-access-token \
  --resource xratu-control-plane \
  --query accessToken -o tsv)"

AWS

TOKEN="$(cat "${AWS_WEB_IDENTITY_TOKEN_FILE}")"

This is the web-identity token from an IRSA or web-identity session, which is why it is read from a file rather than minted by a command. If the variable is unset, the environment is not running under a web-identity session.

Generic enterprise OIDC

TOKEN="<external-oidc-token>"

How you obtain it depends on your provider. What matters to Xratu is that its issuer is in the configured allowlist and its audience is accepted, neither of which is true by default. See Custom enterprise OIDC.

Confirm you have one

test -n "${TOKEN}" && echo "external token acquired"

An empty result means the problem is with your provider session, not with Xratu, and no amount of Xratu configuration will fix it.

Then exchange it

xratu auth exchange --provider gcp --external-token "${TOKEN}" --set-token --set-actor

See External identity exchange for what the control plane does with it, and Exchange an external identity for an Xratu token for the task end to end.

Automation

For unattended callers, a provider session is often the wrong shape: it expires, and it ties automation to a human's credentials. A service account issues a token directly from Xratu instead, with no provider token involved. See Create and manage a service account.