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

Allow override of Authorization header in request #2066

Closed
migurski opened this issue May 26, 2014 · 4 comments
Closed

Allow override of Authorization header in request #2066

migurski opened this issue May 26, 2014 · 4 comments

Comments

@migurski
Copy link

I have encountered a situation similar to #927.

I am creating a new request with an explicit Authorization header, e.g.

posted = post('…', headers={'Authorization': '…'}, data=…)

Requests is finding and using an entry from a .netrc file I didn’t know existed; it appears to have been generated by the Heroku toolbelt. This overrides the Authorization header supplied in the headers dictionary.

Can the default behavior instead allow environmental factors to be overridden?

Also, can requests make this behavior in some way easier to discover? I am unable to find a way to retrieve the request headers actually sent; they would have provided a valuable clue about the mystery username & password.

@Lukasa
Copy link
Member

Lukasa commented May 26, 2014

Both of these problems in this case have solutions. To avoid using .netrc, use a Session and set Session.trust_env to False. To see what headers were sent by requests (noting that the lower layers may add more), check response.request.headers.

@sigmavirus24
Copy link
Contributor

This is a duplicate of #2062 and as such, I'm closing this

@migurski
Copy link
Author

Thanks. @Lukasa, can response.request be added to the Response documentation?

@Lukasa
Copy link
Member

Lukasa commented May 26, 2014

@migurski Good idea, and done. See #2069.

@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
None yet
Projects
None yet
Development

No branches or pull requests

3 participants