Bad Credentials error when run in organization using service account
I'm able to run the add-to-project GitHub Action workflow without any issue in a personal repo, and feeling pleased with it, tried to implement it for my organization. Unfortunately, I haven't been able to make it work: I keep getting a "Bad Credentials" error message.
After pushing the add-to-project.yml to the repo, I used a service account with organization 'member' privileges to create a PAT (ensuring it had the same secret name indicated in the .yml file), giving it the 'repo', 'project', and 'workflow' scopes. I then added this service account to the repo as a collaborator with owner/admin rights. Next, I added a repository secret (named the same secret name indicated in the .yml file) to the repo. Testing at this point resulted in a "Bad Credentials" error.
After conducting research, added the following scopes to the token:
- write:org
- read:org
Testing of this change did not work. More research found that some people had to added these additional scopes:
- manage_runners:org
- manage_runners:enterprise
Testing of this scope update still did not work, so I conducted more troubleshooting with the following attempts:
- Creating the PAT from my personal account which has full owner/admin access of the entire org (set as owner/admin to repo)
- Creating the PAT from a different service account which has full owner/admin access of the entire org (set as owner/admin to repo)
- Updating the PAT to have full scope rather than limited to just 'repo', 'project', and 'workflow'
- Create environment secret instead of repo secret (done with service account 1 and service account 2)
- Create org secret instead of repo secret (done with service account 1 and service account 2)
Each test run resulted in the same "Bad Credentials" error. Not sure if I hit a bug, or if implementation for an org is different.
In this issue https://github.com/actions/add-to-project/issues/264 I see the output that for organizations a Github App is recommended but this is not documented in this README so maybe you need an App. I also wanted to have a similar setup (and assume many other people will do) but the access issues seem to be really annoying. Even having to add a PAT on the organizational level is difficult and there should be a way to link a Project to a repo IMO.
I just wanted to say that I also had the same issue. Hoping this issue will be resolved soon 😄
I also have the same issue. And it is complicated by the action not working with Projects (classic). I migrated my project to an org project and now have to deal with authentication at the org level rather than repo level.