Skip to content
  1. LuzineDebug
  2. DevOps, servers & cloud
  3. Error: Unhandled error: HttpError: Resource not…
DevOps, servers & cloud Intermediate ≈ 10 min to fix

Fix "Resource not accessible by integration" in GitHub Actions

Error message
Error: Unhandled error: HttpError: Resource not accessible by integration
  • RequestError [HttpError]: Resource not accessible by integration
  • remote: Permission to user/repo.git denied to github-actions[bot]. fatal: unable to access 'https://github.com/user/repo/': The requested URL returned error: 403
  • Error: Resource not accessible by personal access token
  • GitHub Actions is not permitted to create or approve pull requests.
  • Error: HttpError: Resource not accessible by integration - https://docs.github.com/rest/issues/comments#create-an-issue-comment
In short

The workflow’s GITHUB_TOKEN is not allowed to make the requested call (comment on a PR, push, create a release…). Declare the needed permissions with a permissions: block in the workflow, for example contents: write or pull-requests: write; for a pull request from a fork, the token stays read-only.

Be the first to confirm this fix

What this error means

Every GitHub Actions run gets a temporary token, GITHUB_TOKEN, issued by the "GitHub Actions" GitHub App: hence the word "integration". Its rights are limited by three things: the repository or organisation setting (read-only by default for repositories created since 2023), the workflow’s permissions: block, and the event context (fork, Dependabot). When an action calls the REST or GraphQL API for an operation those rights do not allow, GitHub answers 403 and the Octokit library prints Resource not accessible by integration. With a fine-grained personal access token, the same problem reads by personal access token.

Common causes

  1. Read-only token by default: the repository or organisation is set to "Read repository contents and packages permissions".
  2. Incomplete permissions: block: as soon as you declare one, every permission not listed becomes none.
  3. Pull request from a fork or by Dependabot: for the pull_request event, GitHub forces a read-only token, whatever your settings.
  4. Access to another repository: GITHUB_TOKEN only works for the workflow’s repository; it cannot clone or push to another private repository.
  5. PR creation forbidden: the "Allow GitHub Actions to create and approve pull requests" option is unchecked in the settings.

Step-by-step fix

  1. See the token’s actual permissions

    In the run log, open the "Set up job" step: the "GITHUB_TOKEN Permissions" section lists the granted rights. Also find which step and which API call failed.

  2. Declare permissions in the workflow

    This is the right fix: grant at job level only what it needs. Also list contents: read if the job runs a checkout, because permissions not mentioned become none.

    yaml
    jobs:
      comment:
        runs-on: ubuntu-latest
        permissions:
          contents: read
          pull-requests: write
          issues: write
        steps:
          - uses: actions/checkout@v4
          - 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 OK',
                });
  3. Pick the right permission

    contents: write to push, create a tag or a release; pull-requests: write to comment on or edit a PR; issues: write for issues and labels; packages: write to publish to GHCR; id-token: write for OIDC authentication to AWS, Azure or GCP; pages: write for GitHub Pages.

  4. Check repository and organisation settings

    In Settings > Actions > General > Workflow permissions, the organisation setting caps the maximum a workflow can request. Check "Allow GitHub Actions to create and approve pull requests" only if a workflow must open PRs.

  5. Forks: split the privileged work

    Do not use pull_request_target while running the PR’s code: a malicious contributor would get a write token and your secrets. Run the tests on pull_request (read-only), then a second workflow_run workflow that posts the comment.

    yaml
    on:
      workflow_run:
        workflows: ["CI"]
        types: [completed]
    
    permissions:
      pull-requests: write
  6. Access to another repository: GitHub App token

    Create a GitHub App installed on both repositories, store its ID and private key as secrets, and generate a short-lived token in the workflow. This is safer than a personal token tied to your account.

    yaml
    - uses: actions/create-github-app-token@v1
      id: app-token
      with:
        app-id: ${{ vars.APP_ID }}
        private-key: ${{ secrets.APP_PRIVATE_KEY }}
        owner: ${{ github.repository_owner }}
    - uses: actions/checkout@v4
      with:
        repository: my-org/other-repo
        token: ${{ steps.app-token.outputs.token }}

Did this fix work for you?

Confirm it in one click: it will rise for the next developers stuck on the same error.

Keep it from coming back

  • Put permissions: contents: read at the top of every workflow and grant write access job by job: least privilege.
  • Also test workflows that comment or push on a PR from a fork before rolling them out on an open source project.
  • Prefer GitHub App tokens or OIDC over personal tokens stored as secrets.

Frequently asked questions

Why does it work on my PRs but not on contributors’ ones?

PRs from a fork always get a read-only GITHUB_TOKEN and no access to secrets, so a stranger cannot take over the repository. Use a separate workflow_run workflow for write actions.

Should I check "Read and write permissions" in the settings?

It fixes the error, but gives write access to every workflow. Better keep read-only as the default and add permissions: only to the jobs that need it.

What about "Permission to repo.git denied to github-actions[bot]" on git push?

Same cause: the token lacks contents: write. Add it to the job; if the branch is protected, direct pushes are still refused and you need to open a PR.

Useful tools for this error

More DevOps, servers & cloud errors

All DevOps, servers & cloud errors →