Skip to main content
Use Google Cloud workload identity federation to exchange a Trigger.dev OIDC token for a short-lived Google access token. Your tasks call Google Cloud APIs with no service account key in GOOGLE_APPLICATION_CREDENTIALS or GOOGLE_CREDENTIALS. Follow the OIDC prerequisites, then go to the OIDC page for your environment and copy the issuer URL and subject.

Configure Google Cloud

Create a pool and provider

Create a workload identity pool, then an OIDC provider in it. Replace the IDs, your organization slug, and your project number:
The allowed audience is the provider’s own resource URL, which your task requests below. The mapping makes each Trigger.dev environment subject a distinct Google principal.
Google limits google.subject to 127 characters. Production and Staging subjects are well under that. A Preview subject ends with the branch’s slug, so a long branch name can push it over the limit and Google rejects the token. Check the length of the subject you copy before using it for a Preview environment.

Grant access to the subject

Grant roles to the principal for the complete subject copied from the dashboard. For the example below, allow reading objects in a bucket:
Some Google APIs don’t accept federated principals directly. For those, grant the principal roles/iam.workloadIdentityUser on a service account and impersonate it (see service_account_impersonation_url below).

Use the identity in your task

IdentityPoolClient from google-auth-library asks a subject token supplier for a token whenever it needs a new Google access token. Return a fresh Trigger.dev OIDC token from it:
/trigger/read-from-gcs.ts
The STS audience is the provider URL without a scheme; the OIDC token’s audience is the same URL with https:, matching --allowed-audiences. Create the client inside run so one run’s tokens are never reused by another. Redeploy and start a new run on that deployment.

Remove the old credential

Once runs in every deployed environment authenticate this way, delete GOOGLE_APPLICATION_CREDENTIALS and GOOGLE_CREDENTIALS from those environments on the Environment Variables page, then delete the service account key in Google Cloud. Local Development runs can’t mint OIDC tokens. Use your own credentials there, such as gcloud auth application-default login, when ctx.environment.type === "DEVELOPMENT".