Python3 using requests to grab HTTP Auth Data

Michael Torrie torriem at gmail.com
Wed Feb 1 16:41:05 EST 2017


On 02/01/2017 01:51 PM, Νίκος Βέργος wrote:
> as well as input() for both user & pass combo but iam not getting in chrome the basic pop-up HTTP auth window.
> 
> Any idea why?

What you're describing is not something you can do with an interactive
Python script.  HTTP-level authentication is requested of your browser
by the web server itself.  On Apache there are numerous methods you can
use.  Individual users can use .htaccess directives to add
authentication to a directory, for example.  You'll need to learn about it:
https://www.google.com/search?q=apache+http+authentication

If you're using a framework like Django, there are mechanisms for
checking the username and password against a Python method.  Again,
google for http authentication and whatever framework you're using.

I once used a special python script that was called by an Apache module
to verify users against a customized LDAP filter.  Again, that involves
server cooperation though a module.

In general, the browser pops up the username and password box in
response to a request from the web server.  It's not something your CGI
script can just do without some cooperation from the web server.



More information about the Python-list mailing list