Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 640
roy Avatar asked Nov 02 '16 03:11

roy


1 Answers

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.

like image 145
Manali Avatar answered Oct 08 '22 07:10

Manali