Python Forum
Prompt of Access ( Authentication Http ) ? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Prompt of Access ( Authentication Http ) ? (/thread-38896.html)



Prompt of Access ( Authentication Http ) ? - JohnnyCoffee - Dec-07-2022

I'm doing some authentication tests through the http header, but the browser's login prompt window isn't being triggered? I think I'm forgetting something, below is the example:

from wsgiref.simple_server import make_server


def app(environ, start_response):

    status = "401 Unauthorized"
    headers = [
        ("Content-type", "text/plain; charset=utf-8"),
        ("WWW-Authenticate:", "Basic realm=Access to the internal site")
    ] 
    start_response(status, headers)

    # The returned object is going to be printed
    return [b"401 Unauthorized"]

with make_server("", 8000, app) as httpd:
    print("Serving on port 8000...")

    # Serve until process is killed
    httpd.serve_forever()



RE: Prompt of Access ( Authentication Http ) ? - nilamo - Dec-09-2022

Quote:
       ("WWW-Authenticate:", "Basic realm=Access to the internal site")

Try it without a colon in the header name :)