"message": "Resource not accessible by integration"


I’m trying to set a new GitHub Actions secret with the below Curl call using the Github API, but it is returning this message with status code 403:

Resource not accessible by integration

This is the Curl Call in which I am trying to use:

curl \
  -X PUT \
  -H "Accept: application/vnd.github.v3+json" \
  -H "authorization: token ${{ secrets.GITHUB_TOKEN }}"\
  https://api.github.com/repos/splunk/$repo_name/actions/secrets/SECRET_TOKEN \
  -d '{"encrypted_value": ${{ secrets.SECRET_TOKEN }} }'

Am I doing something wrong?

I’ll be very grateful for your help. Thanks!

Is the repo you are trying to set the secret in the same repo the workflow is running in?

No, it is a different repo.
What we are trying to do is copy one repos secrets to another repos secrets so that we don’t have to do it manually, without using the organization secrets since we are not permitted from using that option for now.

You won’t be able to use the $GITHUB_TOKEN, as its permissions are scoped to just the repo that triggered the workflow. You’ll have to create a Personal Access Token (PAT) that has access to the other repos, and use that.