1

I have used GitHub API to access private repositories using the Authorization header. This works very well. But, I am unable to see the the repository i.e. send a GET request for the repository webpage.

Suppose the url I want to access is

url = 'https://github.com/username/repo'

which is the link to my private repository. And I have

headers = {'Authorization': 'token mygithubtoken'}
auth = {'myusername', 'mypassword')

I am sending a get request as following

>>> res = requests.get(url, auth=auth, headers=headers)

>>> print(res.status_code)
404

I want to do this because the diff of a pull request is also not accessible this way which is located at https://github.com/user/repo/pull/pr_no.diff

1 Answer 1

2

I contacted GitHub support and they answered it. We can't use OAuth tokens to access the website. However, diffs are available through the API:

https://developer.github.com/v3/pulls/#get-a-single-pull-request

you can pass in the application/vnd.github.VERSION.diff media type to get the diff. So that would make my

url = https://api.github.com/repos/:owner/:repo/pulls/:number

and

headers = {
    'Authorization': 'token mygithubtoken',
    'Accept': 'application/vnd.github.VERSION.diff',
}

Thanks GitHub support for this !

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.