Programming

How to Use Vercel CLI OIDC Token Exchange in CI Without Long-Lived Deployment Tokens

Replace a stored Vercel Personal Access Token in CI with a short-lived CLI token exchanged from your workload’s OIDC identity. Learn what to configure, how to scope access, and how to handle commands that still require a user token.

A CI deployment often needs credentials to run Vercel CLI commands. A common approach is to store a Personal Access Token (PAT) as a CI secret and make it available to deployment jobs. That can work, but it leaves a long-lived credential in the workflow’s secret store.

Vercel CLI now supports exchanging an OIDC token from a trusted workload—such as a GitHub workflow—for a short-lived Vercel CLI access token. Vercel calls this Workload Identity Federation (WIF). Its OIDC policies determine what the resulting token can do, and Vercel recommends migrating CI/CD workflows from PATs to OIDC.

This tutorial walks through the migration as a sequence: check whether your commands are eligible, create a policy, configure the CI workload to obtain a token, exchange it, and test the deployment. The supplied documentation excerpt confirms the exchange model, but does not include the exact CLI invocation or provider-specific workflow configuration. For those commands, use Vercel’s current OIDC CLI documentation rather than copying an unverified example.

What changes when CI uses OIDC?

With a PAT, a workflow retrieves a stored credential and uses it to authenticate. The credential exists independently of an individual job and must be managed as a secret.

With OIDC token exchange, the workload presents an OIDC token issued by its CI provider. Vercel exchanges that token for a short-lived CLI access token. The team’s OIDC policy controls the access granted; it is not simply the permissions of a particular team member. The token grants only what the policy allows.

flowchart LR
    A["CI job"] -->|"OIDC identity"| B["Vercel token exchange"]
    B -->|"Short-lived CLI token"| C["Vercel CLI command"]
    D["Team OIDC policy"] --> B

The diagram shows the documented relationship between the workload identity, policy, exchange, and CLI access. It does not specify a provider’s token endpoint, a CLI flag, or the content of a particular policy; those implementation details must come from the current documentation and your team’s configuration.

The security improvement is not that all risk disappears. A job that can request OIDC identity and run deployment commands still needs to be protected. The change is that you do not need to keep a long-lived PAT in the CI secret store for commands that support the exchange flow.

1. Inventory the commands your pipeline runs

Before changing credentials, list every Vercel CLI command in the workflow. Include commands in build scripts, deployment scripts, and package scripts—not just the obvious deploy step.

For example, your repository might have a script that calls the CLI indirectly:

{
  "scripts": {
    "deploy:production": "vercel deploy --prod"
  }
}

This snippet is only an illustration of where to look; it is not a claim about the exact authentication syntax or supported behavior of this command. Inspect the actual commands in your repository and compare them with Vercel’s OIDC documentation.

That check matters because Vercel’s announcement says some CLI commands still require a user token. Do not assume that every CLI operation can use the exchanged token. If a command is excluded, decide whether to remove it from CI, replace it with a supported operation, or retain a separate credential for that command under an explicit exception.

A simple inventory table makes the migration reviewable:

Workflow step Command or script OIDC support confirmed? Action
Build Project build script Check the commands it invokes Keep or investigate
Deploy Vercel deployment command Check the current CLI docs Migrate if supported
Account or user operation Any user-scoped command Do not assume support Verify or separate

The table is a planning aid, not a list of guaranteed supported commands. Mark a command “confirmed” only after checking current Vercel documentation for that operation.

2. Add a team OIDC policy

Vercel identifies two ways to start: add a Vercel CLI policy in Settings → Build and Deployment → OIDC Policies, or use the new vercel oidc-policies command. Choose the method that fits your team’s review process. A UI change may be convenient for an initial setup; a CLI-based approach may fit a team that manages configuration through its normal operational workflow. The announcement establishes that the command exists, but does not provide its subcommands or argument syntax.

Create the policy for the workload you intend to authorize. In particular, avoid treating “CI” as a reason to grant broad access. The policy is the control point: each exchanged token receives only the access that policy allows. Decide which workload should be trusted and which operations it needs before enabling the workflow.

Use Vercel’s policy documentation to define the actual matching conditions and permissions. The source excerpts supplied here do not establish the names of policy fields, supported identity claims, or a policy file format, so do not invent those values or paste a guessed JSON document into production.

A safe setup sequence is:

  1. Identify the repository and CI workload that will deploy.
  2. Review the claims and configuration your CI provider supplies, using that provider’s documentation and Vercel’s current policy instructions.
  3. Create a policy that matches the intended workload and grants only the required Vercel access.
  4. Review the policy with the team that owns the Vercel project or team.
  5. Save the policy and record how it can be audited or changed.

This is where the main authorization decision happens. A short-lived token can still be too powerful if the policy grants more access than the job needs.

3. Configure the CI job to present its OIDC identity

The CI job must be a trusted workload that can obtain an OIDC token from its provider. Vercel’s announcement explicitly names GitHub workflows as an example of a trusted workload, but it does not give a GitHub Actions YAML example or specify permission settings. Follow the provider-specific instructions in Vercel’s CLI OIDC guide and your CI provider’s documentation to enable the required identity request.

Keep this configuration limited to the job that needs Vercel access. Do not expose the exchanged token to unrelated build steps, print it to logs, or pass it to untrusted scripts. These are operational safeguards for handling a credential; they do not change the token exchange mechanism.

A provider-specific workflow needs to do three things in the right order:

  1. Run in the trusted CI context covered by the team’s policy.
  2. Obtain the provider-issued OIDC token using the provider’s supported mechanism.
  3. Exchange that token through the Vercel CLI flow documented for your installed CLI version, then run only the eligible Vercel commands.

Do not substitute a generic OIDC token or an ID token intended for another audience. The supplied excerpts do not specify the required audience, issuer, or exchange command-line flags. Those values are precisely the details to take from the current official instructions, not infer from an unrelated provider example.

4. Exchange the token and run a deployment

Once the policy and workload configuration are in place, use the documented Vercel CLI OIDC exchange flow in the job before the first Vercel command that needs authentication. The high-level flow is:

CI provider issues workload OIDC token
        ↓
Vercel CLI exchanges that token
        ↓
CLI receives short-lived Vercel access token
        ↓
Eligible Vercel CLI operation runs

This is a process illustration, not executable shell syntax. The supplied source excerpts do not include the command name, environment variable, flags, or response handling. Consult the current CLI documentation for those exact details and use the invocation shown there. Avoid relying on a third-party snippet unless you independently verify it against the official documentation and the version of the CLI installed in CI.

After adding the exchange step, keep the deployment command and its inputs as close as possible to the existing workflow. A narrow change makes failures easier to diagnose: first replace how the job authenticates, then change deployment behavior separately if necessary.

If your team pins or otherwise controls its CLI version, verify that the version in the CI environment supports OIDC token exchange. The announcement says the CLI supports the feature, but the supplied excerpt does not give a minimum version or installation command. Do not guess one; check the CLI documentation and your actual versioning policy.

5. Test the migration without silently falling back to a PAT

A migration is not complete if the job succeeds only because it still has access to the old secret. Test the OIDC path deliberately:

  1. Apply the policy and provider configuration in a non-production workflow or an appropriately controlled test run.
  2. Use the official exchange procedure and run a Vercel CLI operation that your inventory confirms is supported.
  3. Confirm the job succeeds without retrieving the old PAT.
  4. Check CI logs and workflow configuration to ensure credentials are not printed or copied into artifacts.
  5. Test a denied or untrusted workload where practical, so the team can confirm the policy does not authorize every job by accident.
  6. After the OIDC path is verified, remove the PAT from workflows that no longer need it and follow your organization’s process for removing or rotating the old credential.

The sixth step is important: leaving the PAT wired into the job as a fallback preserves the old credential exposure. If you need a temporary rollback, make it deliberate, time-limited, and visible rather than allowing an automatic fallback that masks a broken OIDC setup.

For diagnosis, separate identity failures from authorization failures. If the workload cannot obtain a provider token, investigate the CI provider setup. If it obtains a token but Vercel rejects the exchange, check the policy and the identity attributes against the official configuration guide. If exchange succeeds but a CLI operation is denied, verify that the command is supported and that the policy grants the necessary access. The supplied excerpts do not document specific error messages, so use current CLI output and official troubleshooting guidance rather than matching errors to guessed causes.

6. Handle commands that still need a user token

Vercel’s announcement explicitly warns that some CLI commands still require a user token. Treat that as a migration boundary, not as a reason to keep a PAT in every deployment job.

For each unsupported command, choose one of these approaches:

  • Remove it from the automated deployment path if it is not necessary.
  • Move it into a separate, controlled workflow that has a documented reason for using a user token.
  • Replace it with a supported operation, after verifying that the alternative has the required behavior.
  • Keep a narrowly scoped exception only if your team’s Vercel setup and credential controls permit it.

Do not claim that a user-token exception is equivalent to OIDC. It retains a different credential model, so document its owner, purpose, storage location, and review process. The goal is to remove long-lived tokens from routine CI where OIDC is supported, not to pretend that every legacy or user-scoped operation has already been migrated.

Common migration mistakes

Assuming every command supports OIDC

The announcement says some commands still require a user token. Audit the full command path, including scripts called by the workflow, and verify each operation against the current docs.

Creating a policy that is broader than the workload

The policy controls what the exchanged token can do. A successful exchange does not prove that the policy is appropriately narrow. Review the authorization granted, and do not grant broad access merely to make an initial test pass.

Copying an unverified workflow example

The source excerpt confirms the feature and names GitHub workflows as an example, but does not include configuration syntax. Use the official guide for exact provider and CLI steps. Do not turn a search snippet or an unrelated example into a production configuration.

Leaving the old PAT as an invisible fallback

A workflow that can still use the PAT may pass even if OIDC is misconfigured. Remove the secret reference after the new path works, or keep any exception separate and explicitly documented.

Treating short-lived credentials as risk-free

Short-lived access reduces dependence on a long-lived stored token, but a job that is trusted by policy can still request access. Protect the workflow, restrict which workload is trusted, and keep the policy aligned with the job’s actual needs.

A practical migration checklist

Before merging the change, confirm:

  • The team has an OIDC policy created through Vercel Settings or the documented vercel oidc-policies command.
  • The policy matches the intended CI workload and grants only the access required.
  • The provider-side OIDC setup follows current provider and Vercel instructions.
  • The installed Vercel CLI version supports the documented exchange flow.
  • Every command in the CI path has been checked for OIDC support.
  • The workflow does not expose the exchanged token in logs or unrelated steps.
  • The successful test run does not depend on the old PAT.
  • Any remaining user-token command is isolated and documented.

The resulting design is straightforward: the trusted CI workload proves its identity, Vercel evaluates that identity under the team’s OIDC policy, and the CLI uses short-lived access for supported operations. That replaces a stored PAT for the parts of the pipeline that can use the exchange flow, while leaving a clear, reviewable exception path for commands that still require a user token.

External Sources used for this article

Related Articles

View all →