<p dir="auto">I have encountered a situation similar to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="8185272" data-permission-text="Title is private" data-url="https://github.com/psf/requests/issues/927" data-hovercard-type="issue" data-hovercard-url="/psf/requests/issues/927/hovercard" href="https://github.com/psf/requests/issues/927">#927</a>.</p>
<p dir="auto">I am creating a new request with an explicit <code class="notranslate">Authorization</code> header, e.g.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="posted = post('…', headers={'Authorization': '…'}, data=…)"><pre class="notranslate"><code class="notranslate">posted = post('…', headers={'Authorization': '…'}, data=…)
</code></pre></div>
<p dir="auto">Requests is finding and using an entry from a <code class="notranslate">.netrc</code> file I didn’t know existed; it appears to have been generated by the Heroku toolbelt. This overrides the Authorization header supplied in the <code class="notranslate">headers</code> dictionary.</p>
<p dir="auto">Can the default behavior instead allow environmental factors to be overridden?</p>
<p dir="auto">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 &amp; password.</p>
<p dir="auto">Hi,</p>
<p dir="auto">And thanks for maintaining requests. When I set an Authorization header in a request, I do not expect it to be overwritten. I set up default credentials in my .netrc file (for automatizing the cadaver command line tool), and suddenly I could not authenticate to my service any longer.<br>
Please check if an Authorization header does already exist in your default authorization handler, instead of overwriting it. I see that you documented this behaviour in the authentication section, but since I never used this form of authentication it took quite some time to find the problem. Also, overwriting a header that the user set does not seem to be a sensible implementation.</p>
<p dir="auto">Thanks,<br>
Joe</p>