Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth fail for private github repo #56

Closed
mw44118 opened this issue Jun 4, 2011 · 6 comments
Closed

Auth fail for private github repo #56

mw44118 opened this issue Jun 4, 2011 · 6 comments
Labels

Comments

@mw44118
Copy link

mw44118 commented Jun 4, 2011

I've got a private repo here on github. I want to suck down all the issues. This works in curl (password removed):

$ curl -u "mw44118:XXXXXXXX" https://api.github.com/repos/spothero/SpotHero-Splash-Page/issues
{ 
... real data here
}

And this is what happens when I don't include the -u authentication stuff:

$ curl https://api.github.com/repos/spothero/SpotHero-Splash-Page/issues
{ 
  "message": "Not Found"
}

Then I tried the same thing with requests (again XXXXXX ain't really my password):

>>> requests.get('https://api.github.com/repos/spothero/SpotHero-Splash-Page/issues', auth=('mw44118', 'XXXXXXXX'))
<Response [404]>

I wondered if maybe you don't actually send the auth stuff unless the server replies with a 403, and since github is replying with a 404, the requests code never knows to send the credentials.

I tried reading through the requests code, but didn't see anything that supported that guess.

@kennethreitz
Copy link
Contributor

I'm going to have to play with this. #74 may fix the problem, once it is implemented.

@jonashaag
Copy link

Same problem here. From Wireshark,

requests.get('https://api.github.com', auth=('user', 'pass'))

seems to not send the HTTP authentication headers.

@kennethreitz
Copy link
Contributor

I'm going to get on this tonight.

It's because GitHub's api isn't asking for authentication.

@kennethreitz
Copy link
Contributor

Until I figure out a good method for overriding default HTTP behavior, you can do this:

http://stackoverflow.com/questions/2407126/python-urllib2-basic-auth-problem/2955687#2955687

@kennethreitz
Copy link
Contributor

Alright, a new ForcedHTTPBasicAuthenticationHandler was added, and it's default.

This should work fine now::

requests.get('https://api.github.com', auth=('user', 'pass'))

:)

@mw44118
Copy link
Author

mw44118 commented Jul 24, 2011

Thanks for writing this!

I just ran easy_install -U and now it seems to work, because I get a <Response 200> instead of the <Response 404>.

Of course when I tried to read from the response, I got a huge stream of gibberish, but I'll try to figure that out myself.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants