Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

GitHub Actions cannot get ACTIONS_ID_TOKEN_REQUEST_URL (OIDC token)

ErrorUnable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable

Short answer

The runner only sets ACTIONS_ID_TOKEN_REQUEST_URL when the job may request an OIDC token. Without id-token: write the token cannot be requested. Add it at workflow or job level, keep contents: read if you check out code, and for reusable workflows set it on the caller too.

  • Applies to GitHub Actions, actions/deploy-pages v4
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Show every permissions block in the workflow and note which job each one belongs to. The job that fails must be allowed to request the token.

    grep -n -B1 -A6 'permissions:' .github/workflows/*.yml
  2. 2Match what you see, then jump to its fix

    1. 1No permissions block, or one that lists contents or pages but not id-tokenid-token: write is missingFix
    2. 2id-token: write sits in one job or at the top, but the failing job has a permissions block without itid-token is set at the wrong levelFix
    3. 3The deploy job lives in a called workflow owned by a different org or enterpriseThe job runs from a reusable workflow in another organizationFix

What does the error look like?

  • Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable

Cause 1 of 3

id-token: write is missing

1Check

The OIDC reference says that without id-token: write the token cannot be requested. Permissions you do not list are set to none once you write a permissions block.

grep -n 'id-token' .github/workflows/*.yml || echo missing

2Fix

Add id-token: write to the job that needs the token (Pages deploy jobs need it, as do actions that log in to a cloud with OIDC). It only allows fetching the token; it grants no write access to repository content.

permissions:
  contents: read
  id-token: write
  pages: write

3Verify

Re-run the job; the variable error is gone.

gh run rerun --failed

Confirmed by docs.github.com

Did this fix it?

Cause 2 of 3

id-token is set at the wrong level

1Check

permissions works as a top-level key for all jobs or inside a single job. Put the permission where the job that requests the token can use it.

grep -n -B3 -A6 'jobs:' .github/workflows/deploy.yml

2Fix

Repeat id-token: write inside the job's permissions block.

jobs:
  deploy:
    permissions:
      id-token: write
      pages: write

3Verify

Re-run the failing job; the token step passes.

gh run rerun --failed

Confirmed by docs.github.com

Did this fix it?

Cause 3 of 3

The job runs from a reusable workflow in another organization

1Check

For reusable workflows in the same user, organization or enterprise the token is available from the caller's context. For one outside, the docs say to set id-token to write explicitly in the caller.

grep -n -B2 -A8 'uses: .*/.github/workflows' .github/workflows/*.yml

2Fix

Set id-token: write on the caller workflow or the calling job.

jobs:
  call:
    permissions:
      id-token: write
      contents: read
    uses: other-org/shared/.github/workflows/deploy.yml@main

3Verify

Re-run the caller workflow.

gh run rerun --failed

Confirmed by docs.github.com

Did this fix it?

How do I stop it coming back?

  • Give id-token: write to the deploy job only, not the whole workflow.
  • Copy the permissions block from the action's README when you add a new deploy action.
  • Re-read permissions whenever a job gets its own permissions block.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Servers

docker pull or push to ghcr.io fails with 'denied'

Error response from daemon: denied

ghcr.io refuses a pull or push when Docker is not logged in, when the token lacks the package scope, or when the workflow's GITHUB_TOKEN has no packages permission or no access to that package.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.