canonical: https://jentic.com/apis/googleapis.com/iam-credentials

# Google IAM Service Account Credentials API

The IAM Service Account Credentials API mints short-lived credentials for Google Cloud service accounts. A caller with iam.serviceAccountTokenCreator on a target service account can request a 1-hour OAuth 2.0 access token, an OpenID Connect ID token, a signed JWT, or a signed binary blob, all issued in the target service account's identity. This is the standard mechanism for service-account impersonation, workload identity federation, and key-less signing on Google Cloud, replacing the practice of distributing long-lived service-account JSON keys.

## For AI agents

Mint short-lived OAuth access tokens, ID tokens, signed JWTs, or signed blobs in the identity of a Google Cloud service account, without distributing private keys.

## Scope

Does not create service accounts, manage IAM bindings, or rotate keys - use for minting short-lived credentials for existing service accounts only.

## Capabilities

- Generate a 1-hour OAuth 2.0 access token in the identity of a target service account
- Mint an OpenID Connect ID token with a custom audience for service-to-service authentication
- Sign a binary blob using the target service account's private key without exposing the key
- Sign a JWT payload as the target service account for use with Google or third-party services
- List allowed locations for a service account to support residency-aware credential issuance

## Use cases

### Key-less Service Account Impersonation

Platform teams remove long-lived service-account JSON keys by giving callers iam.serviceAccountTokenCreator on a target service account and using POST :generateAccessToken to mint a 1-hour OAuth token at call time. The caller uses the token for the immediate Google API call, then discards it. This dramatically reduces the blast radius of credential leaks compared with distributing JSON keys.

Example prompt: Call POST /v1/projects/-/serviceAccounts/etl-runner@my-project.iam.gserviceaccount.com:generateAccessToken with a 1-hour lifetime and the cloud-platform scope, and return the resulting accessToken.

### ID Token for Cloud Run-to-Cloud Run Auth

When one Cloud Run service calls another, it mints an OIDC ID token via :generateIdToken with the target service URL as audience and presents it on the outbound request. The receiving service validates the token's audience and issuer. This pattern works identically across Cloud Run, Cloud Functions, and IAP-protected backends.

Example prompt: Call POST /v1/projects/-/serviceAccounts/svc@p.iam.gserviceaccount.com:generateIdToken with audience https://api.example.run.app and includeEmail true, and return the idToken.

### Signed JWT for Third-Party Services

Integrations that need to authenticate to a third-party service via signed JWT (e.g. AWS STS AssumeRoleWithWebIdentity, third-party APIs that accept Google service-account tokens) use :signJwt to sign a payload with the service account's private key. The API never returns the key, only the signed JWT, which is rotated automatically by Google.

Example prompt: Call POST /v1/projects/-/serviceAccounts/federated@p.iam.gserviceaccount.com:signJwt with a payload containing iss, sub, aud, and exp, and return the signedJwt.

### AI Agent Just-in-Time Credentials

An AI agent acting on Google Cloud uses Jentic to call :generateAccessToken whenever it needs to access a downstream Google API. The agent never holds a long-lived service-account key; instead, it requests a 1-hour token in the identity of the right service account for the task. Jentic enforces who the agent is allowed to impersonate via vault scoping.

Example prompt: On behalf of agent role data-reader, call :generateAccessToken on bigquery-reader@p.iam.gserviceaccount.com with the bigquery.readonly scope and a 30-minute lifetime, then use that token to call BigQuery.

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | /v1/{+name}:generateAccessToken | Mint a short-lived OAuth 2.0 access token in the identity of the service account |
| POST | /v1/{+name}:generateIdToken | Mint an OpenID Connect ID token with a custom audience |
| POST | /v1/{+name}:signBlob | Sign a binary blob using the service account's private key |
| POST | /v1/{+name}:signJwt | Sign a JWT payload as the service account |
| GET | /v1/{+name}/allowedLocations | List allowed locations for the service account |

## Key resources

- **ServiceAccounts** — Generate short-lived access tokens, ID tokens, signed JWTs, and signed blobs for service-account impersonation

## Why Jentic

- **Setup:** Wiring the IAM Service Account Credentials API by hand means configuring the caller's OAuth2, refreshing tokens, and building the impersonation request for each target service account yourself. Through Jentic you install once, import the IAM Service Account Credentials API from the API Directory, store the credential once, and your agent calls it.
- **Permission scoping:** The target service account travels in the URL path (/v1/{name}:generateAccessToken), so a rule can pin your agent to one service account: it mints tokens or signatures for that account and nothing else. You choose the operations it may call, so if you allow only generateAccessToken the agent cannot signBlob or signJwt unless you add them.
- **Credential handling:** Your calling principal's credential is stored once, encrypted, by your own Jentic One instance and injected at execution time as a short-lived token. Neither the caller's credential nor any target service account's private key enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'mint service account access token' or 'sign a jwt as a service account', and Jentic returns the matching operation with its request body schema so the agent picks the right method without browsing the reference docs.

## Related APIs

- **Identity and Access Management (IAM) API** — IAM grants the iam.serviceAccountTokenCreator role that authorises calls to this API.
- **Cloud Identity-Aware Proxy API** — IAP-protected services accept the OIDC ID tokens minted by this API as authentication.
- **Cloud KMS API** — Cloud KMS signs blobs using customer-managed keys; IAM Credentials signs as the service account's identity.

## FAQ

### What authentication does the IAM Credentials API use?

Google OAuth 2.0 with the cloud-platform scope. The calling principal must hold iam.serviceAccountTokenCreator on the target service account. Through Jentic the calling credential is stored encrypted and exchanged for a scoped access token at call time.

### Can I generate a token without a service-account JSON key?

Yes. POST /v1/{+name}:generateAccessToken returns a 1-hour OAuth token issued in the target service account's identity, given that the caller has iam.serviceAccountTokenCreator. This is the recommended replacement for downloaded JSON keys.

### What are the rate limits for the IAM Credentials API?

Google enforces per-project quotas on credential-generation endpoints. generateAccessToken and generateIdToken default to thousands of QPS but vary by region; signJwt and signBlob have separate quotas. Exact values are visible in Cloud Console quotas for the IAM Credentials API.

### How do I impersonate a service account for one API call through Jentic?

Search Jentic with 'mint service account access token', load the POST /v1/{+name}:generateAccessToken operation, and execute with name set to projects/-/serviceAccounts/{email} and a body specifying scope and lifetime. Jentic returns an access token the agent can use immediately.

### What is the difference between generateAccessToken and generateIdToken?

generateAccessToken returns an OAuth 2.0 access token used as the Authorization bearer to call Google APIs. generateIdToken returns an OIDC ID token used to authenticate to receivers like Cloud Run, Cloud Functions, or IAP, where the audience claim is checked against the target service URL.

### Can I limit what my agent is allowed to do with the Google IAM Credentials API?

Yes. Because you run Jentic One yourself, your own rules decide which operations and credentials the agent may use. The target service account travels in the URL path of each call, so you can pin the agent to a single account and let it mint tokens or signatures only for that one. You also choose the operations it may call, so if you allow only generateAccessToken the agent cannot reach signBlob, signJwt, or generateIdToken unless you add them.
