Python Forum
Prompt of Access ( Authentication Http ) ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prompt of Access ( Authentication Http ) ?
#1
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()
Reply
#2
Quote:
       ("WWW-Authenticate:", "Basic realm=Access to the internal site")

Try it without a colon in the header name :)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  REST API x.509 authentication crossover 1 2,501 Feb-15-2022, 12:21 AM
Last Post: snippsat
  ModuleNotFoundError: No module named 'http.client'; 'http' is not a package abhishek81py 1 15,529 Jun-25-2020, 08:58 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020