Resource not accessible by integration when using Github App token #69154
-
Select Topic AreaBug BodyHi, I am trying to create a When running the workflow I get the error Workflow filename: Update docs
on:
workflow_dispatch:
gollum:
jobs:
docs:
runs-on: arc-runner-k8s
permissions:
contents: write
steps:
- name: Generate a token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PEM }}
- name: Install curl
run: |
sudo apt update
sudo apt install curl -y
- name: Trigger the action
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ steps.generate_token.outputs.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/unipoll/gollum-test/dispatches \
-d '{"event_type":"update_submodules"}' |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
The error message "Resource not accessible by integration" typically occurs when the GitHub App token does not have the necessary permissions to access the requested resource. In your case, you are trying to create a repository_dispatch event using a GitHub App token for an organization. The error suggests that the token does not have the required permissions to access the repository or perform the requested action. To resolve this issue, you need to ensure that the GitHub App has the appropriate permissions and access to the repository. Here are a few steps you can follow: Verify GitHub App permissions: Additionally, the error message you received suggests that the resource you are trying to access is not found. Make sure to double-check the repository name and API endpoint in your curl command. The https://api.github.com/repos/unipoll/gollum-test/dispatches endpoint you provided should be valid if the repository exists, but it's worth confirming the repository name and organization. |
Beta Was this translation helpful? Give feedback.
-
Okay, I figured it out. I tried manually generating a JWT token and then using it to generate app installation token, and managed to trigger a repository. (Guess this is a good way to check the app permissions) As always, I missed a small detail which caused all the trouble. The actions/create-github-app-token by default only generates a token for the current repository. To generate a token for all repositories it's important to specify owner, i.e. steps:
- name: Generate a token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PEM }}
# Set the owner, so the token can be used in all repositories
owner: ${{ github.repository_owner }} @glauccoslima, thank you for the help, your reply might be useful for other people ! |
Beta Was this translation helpful? Give feedback.
-
@mike-pisman |
Beta Was this translation helpful? Give feedback.
Okay, I figured it out. I tried manually generating a JWT token and then using it to generate app installation token, and managed to trigger a repository. (Guess this is a good way to check the app permissions)
As always, I missed a small detail which caused all the trouble. The actions/create-github-app-token by default only generates a token for the current repository. To generate a token for all repositories it's important to specify owner, i.e.
owner: ${{ github.repository_owner }}