Search code examples
flaskwerkzeug

How to extract user from url in flask request?


I just need to extract user in url i.e. https://user@host:port/path

From flask docs I have already try

  • request.environ
  • request.headers
  • request.host_url ... others apis containing url word.

but not found things I need above

Thank for helping in advances.


Solution

  • When you use user@ syntax in a URL, you're using HTTP authentication. Werkzeug will make the username and password from HTTP authentication available as attributes of request.authorization.