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

authentication fails #130

Closed
jcomeauictx opened this issue Apr 9, 2016 · 8 comments
Closed

authentication fails #130

jcomeauictx opened this issue Apr 9, 2016 · 8 comments
Labels

Comments

@jcomeauictx
Copy link

something, I'm guessing the requests library, is turning the Authorization header from Bearer to Basic, which causes authentication to fail.
droplet.py.txt
droplet.log.txt

@jcomeauictx
Copy link
Author

I have requests version 2.4.3

@jcomeauictx
Copy link
Author

requests 2.7.0 no help either.

@koalalorenzo
Copy link
Owner

If it is a request problem, maybe we should open an issue there, instead of python-digitalocean
Can you confirm that this is a bug related to request? I had no time to test it. I will do it probably tomorrow.

@jcomeauictx
Copy link
Author

I cannot confirm at this time. but since this bug makes the library unusable, wouldn't you want to know anyway, so you could code around the problem?

@koalalorenzo
Copy link
Owner

since this bug makes the library unusable, wouldn't you want to know anyway, so you could code around the problem?

OFC. That's why I will check tomorrow ;-) I suggest you to do the same!
I admit that request in past caused some errors because they changed the way they were using options for specific methods. I will check tomorrow after some sleep! ;-)

@jcomeauictx
Copy link
Author

OK thanks.

@koalalorenzo
Copy link
Owner

It works fine for me, using also requests v 2.4.3
I am going to trigger some automatic tests to be sure that everything is fine.

I was reading your code without understanding what is happening. Are you sure that your code is not messing up with requests? Have you tried on another OS/Machine? So fare it does not seem a problem. If you find the bug, then feel free to re-open the issue 👍

@fjarlq
Copy link

fjarlq commented Apr 5, 2017

I was hitting the same problem that @jcomeauictx originally reported: my Authorization header was being mysteriously transformed from Bearer into Basic.

I was baffled until I searched for "Basic" in the issues for the requests project, which turned up this recent bug report: psf/requests#3929

That was indeed my problem. I have this line in my $HOME/.netrc to enable automatic login for anonymous FTP:

default login anonymous password anonymous@

requests interprets that to mean it should always override the Authorization header with my .netrc default, even when the caller has explicitly provided an Authorization header.

According to a comment in that bug report, a requests core developer is amenable to changing this behavior in requests 3.0 so that when the caller sets Authorization it won't get overridden.

Until then, perhaps python-digitalocean should consider the advice of requests core developer @Lukasa:

"So it is quite possible that the library wrapping requests should be setting trust_env to False if it is handling headers itself."

Thoughts, @koalalorenzo? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants