Dominik Süß

fighting computers since 1999

Python requests lib silently drops custom auth header


While trying out the cartography project (in particular their github module), I was confronted with weird errors around bad authorization tokens.

On the surface, this code looks correct:

response = requests.get(
    "https://api.github.com/rate_limit",
    headers={'Authorization': authHeader},
)

However, the requests library silently prefers credentials from .netrc if it exists 🤯

This file still had expired credentials for api.github.com in my case from ages ago when I tried out magit forge. Clearing that file solved all issues for me.