[API] Creating repos for a Organisation always results in 403

Hey people,

I’m trying to develop a CLI tool for my organisation. The tool is basically a dev ops utility that creates new repos and applies CI integration to them. So here’s the workflow:

User enters the commands:

$ tool login
Username: github-user
Password: ********

$ tool create repo-name

So the user would first login via the tool. The login uses Basic user/pass to create an authorization token. This token is persisted on the user’s system so that I’m not requiring their credentials every time they wish to create a repo. The token scope I request is repo so it states that I have read/write access to all repos in the users personal account and organisations.

Then the second command would actually create a repository in the Organisation account. However I’m faced with a permissions error:

403 You need admin access to the organization before adding a repository to it.

This is a little strange because I am the owner of the Organisation. So I try and list all the repos in the Organisation using the authenticated token. Success, I can see every repo (public/private). I went a little further and sent the same request to create a repo in the Organisation but this time using Basic Auth user/pass. Success, it let’s me create a repo in the Organisation.

Why is it that the creating an Organisation repo using an auth token get’s 403?

This sounds like the same technique that is used by GitHub’s hub tool which I use quite a lot for creating repositories. I just checked the personal access tokens that it creates and they all have the repo scope, so it sounds like that part is correct. Unfortunately, without seeing the code, I’m not sure that I can give more suggestions because it sounds like you’re doing the right things.

Are you using the POST /orgs/: org/repos endpoint and replacing : org with the name of your organization?