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 doing | Permission |
|---|---|
| Commenting on a pull request | pull-requests: write |
| Commenting on or labelling an issue | issues: write |
| Pushing commits, tags or releases | contents: write |
| Creating check runs | checks: write |
| Publishing to GitHub Packages | packages: write |
| OIDC token for cloud login | id-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:
- Do the write step in a separate workflow that runs after the first one, using the
workflow_runtrigger, which runs in the context of the base repository. - Use
pull_request_targetonly 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. - 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
- Declare
permissions:explicitly in every workflow and job, with the least needed. - Keep the repository default read-only and grant writes per job.
- Test pull request automation from a fork, not only from a branch in the same repository.
- 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.
Related
- Cache Service Responded With 429: FixFix "Failed to restore: Cache service responded with 429" in GitHub Actions: too many cache requests. Upgrade actions/cache, restore once, save once.
- fatal: could not read Username for github.com: FixFix "fatal: could not read Username for 'https://github.com'" in GitHub Actions: private repos, submodules and git dependencies need a token.
- Invalid Workflow File: YAML Syntax Error FixFix "Invalid workflow file" and "You have an error in your yaml syntax" in GitHub Actions: indentation, unexpected value, bad expressions, with actionlint.
- JavaScript Heap Out of Memory in GitHub Actions: FixFix "FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory" and npm ENOMEM in GitHub Actions with NODE_OPTIONS.