Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I do preemptive authentication with httplib2?

I need to perform preemptive basic authentication against an HTTP server, i.e., authenticate right away without waiting on a 401 response. Can this be done with httplib2?

Edit:

I solved it by adding an Authorization header to the request, as suggested in the accepted answer:

 headers["Authorization"] = "Basic {0}".format(
        base64.b64encode("{0}:{1}".format(username, password)))
like image 382
aknuds1 Avatar asked Aug 16 '11 11:08

aknuds1


1 Answers

Add an appropriately formed 'Authorization' header to your initial request.

like image 129
MattH Avatar answered Sep 18 '22 18:09

MattH