Branches protection API


#1

Hi,

$GITHUB_TOKEN is the access token for a organisation installation

I would like to GET the branch protection and maybe PATCH it later, but I get:

$ curl -H ‘Accept: application/vnd.github.loki-preview+json’ -H “Authorization: token $GITHUB_TOKEN” https://api.github.com/repos///branches/master/protection
{
“message”: “Resource not accessible by integration”,
“documentation_url”: “https://developer.github.com/v3
}

I have tested many permissions combination but I always get the error.

The application permissions are currently:
Repository administration -> ReadWrite
Pull requests -> ReadWrite
Repository contents -> ReadWrite
Issues -> Read
Commit statuses -> ReadWrite

Do I miss something ? Does this API endpoint is supported ? if no, any ETA ?


#2

As far as I can tell that endpoint isn’t enabled for GitHub Apps yet:

https://developer.github.com/v3/repos/branches/#get-branch-protection

If you compare the documentation for that endpoint with the documentation for https://developer.github.com/v3/repos/branches/#list-branches you can see a little blue (i) after the list branches one. That means that it’s enabled for GitHub Apps.


#3

I’m still getting a 403 for branch protection, but there’s a (i) next to it now - am I missing something, or does getting branch protection require different permission levels than getting a branch?


#4

@greysteil that endpoint requires the Repository administration permission and is enabled for server-to-server requests. Let me know if you’ve got that permission and you’re unable to access it using an installation token.


#5

Ah OK - that makes a lot of sense, thanks!