Skip to content

Resource Not Accessible by Integration: Fix

Last updated

Resource not accessible by integration is an HTTP 403 from the GitHub API. Your workflow called the API with the GITHUB_TOKEN, and that token does not have the permission the call needs, for example writing a comment on a pull request or creating a release. The fix is almost always a permissions: block, or a different token when the run comes from a fork or Dependabot.

The exact message

HttpError: Resource not accessible by integration
Error: Resource not accessible by integration
RequestError [HttpError]: Resource not accessible by integration - https://docs.github.com/rest/...

Fix 1: grant the permission the call needs

Look at the API endpoint in the error, find which permission it needs in GitHub's permissions for the GITHUB_TOKEN reference and the endpoint's documentation, and add it. Common ones:

You are doingPermission
Commenting on a pull requestpull-requests: write
Commenting on or labelling an issueissues: write
Pushing commits, tags or releasescontents: write
Creating check runschecks: write
Publishing to GitHub Packagespackages: write
OIDC token for cloud loginid-token: write
permissions:
  contents: read
  pull-requests: write

jobs:
  comment:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/github-script@v7
        with:
          script: |
            await github.rest.issues.createComment({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
              body: "Build finished.",
            });

Important detail: as soon as you write a permissions: block, every permission you do not list is set to none. Add contents: read if the job also checks out code. You can set it for the whole workflow or per job, and per job is safer.

Fix 2: check the repository and organisation default

Under Settings, Actions, General, "Workflow permissions" decides whether the default token is read-only or read-write. Newer repositories and organisations default to read-only, and an organisation setting can override the repository. A permissions: block in the workflow works regardless of that default, as long as the organisation has not restricted it.

Fix 3: pull requests from forks and Dependabot

For workflows triggered by pull_request from a fork, GitHub gives the GITHUB_TOKEN read-only access and does not pass repository secrets, so a write permission in the file does not help. Dependabot-triggered runs also get a read-only token by default. Options:

  1. Do the write step in a separate workflow that runs after the first one, using the workflow_run trigger, which runs in the context of the base repository.
  2. Use pull_request_target only if you understand the risk. It runs with write access and secrets, and it must never check out and run code from the pull request. See secure GitHub Actions.
  3. For Dependabot, set the needed secrets under the Dependabot secrets store, not the Actions one.

Fix 4: use a different token when the GITHUB_TOKEN cannot do it

The GITHUB_TOKEN only has access to the repository the workflow runs in. For another repository, for changing workflow files, or for actions that must trigger further workflow runs, use a GitHub App installation token or a fine-grained personal access token with the exact permissions.

How to prevent it

  1. Declare permissions: explicitly in every workflow and job, with the least needed.
  2. Keep the repository default read-only and grant writes per job.
  3. Test pull request automation from a fork, not only from a branch in the same repository.
  4. Prefer a GitHub App token over a personal access token for cross-repository work.

FAQ

Why does it work on my branch but fail on a pull request from a fork?

Fork pull requests run with a read-only token and no secrets, whatever the file says. Use workflow_run for the write step.

Does adding permissions: remove my other permissions?

Yes. Any permission you do not list becomes none, so list everything the job needs.

Is this the same as a 404 or 401?

No. 403 with this message means you are authenticated but not allowed. A 404 can mean a missing repository or one the token cannot see. See Unable to resolve action for action lookups.

Can the GITHUB_TOKEN edit workflow files?

No. It cannot be given permission to change files under .github/workflows. See refusing to allow a GitHub App to update workflow.