roy roy - 1 month ago 5
Python Question

Baffling inability to auth with requests: NoneType error

I am not seeing anyone else have this problem, and it just seems to have cropped up for me. So how do I determine if this is a local install problem or (and I highly doubt this) an issue with the library?

Using

requests
, I have been running the basic authentication for a while without an issue. But today I am finding I can't authenticate at all.

So if I:

import requests
s = requests.Session()
s.auth('username', 'pass')


I immediately get:

---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-1e7d22bf85ad> in <module>()
----> 1 s.auth('user', 'pass')

TypeError: 'NoneType' object is not callable


Doesn't matter if I spin up a new virtual environment and fresh install
requests
. This has never been an issue before and suddenly it is.

Answer

s.auth is an attribute and not a method, so you cannot call it. s.auth = ('username', 'pass') is the assignment you want to use.

Comments