-
Notifications
You must be signed in to change notification settings - Fork 671
fix oauth token access #174
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
Conversation
I think that this will have problems with HTTP requests apart from GET (have you tested PUT/PUSH/DELETE?) 'cause the authorization header is overwritten by basic auth. I fixed all these just yesterday (I wish I could see your request earlier...). Have a look #176 |
@dzervas yes, you are correct, I didn't test with other requests :/ can you please fix example: 3164a0b#diff-8a23d682236897c1a2f5bafede722cb3L28 ? |
I think that the example should not be fixed, as the private key is not static (and you should give that "feel" in the documentation). It's not doing the whole auth thing (you have to talk with the server to gain the key). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my suggestion inline, I think there's a nicer way to handle both oauth and basic HTTP auth.
Thanks!
auth = requests.auth.HTTPBasicAuth( | ||
self.http_username, | ||
self.http_password) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one thing bothering me here: with oauth token we explicitly define headers, with basic HTTP auth we don't and use a python-requests feature instead. I'd prefer to have the same method for both authentication methods.
Updating the _create_headers
method might be the easiest way to achieve consistency. This would also avoid code duplication in the _raw_*
methods.
What do you think about this?
authorization header doesn't have a colon in it's value, requests' auth parameter overrides custom authorization header
(and there was a PEP8 error for line 441)