---
title: "Flask-HTTPAuth | pypx"
description: "HTTP authentication for Flask routes"
canonical_url: "https://pypx.app/packages/Flask-HTTPAuth"
meta:
  "og:description": "HTTP authentication for Flask routes"
  "og:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_Flask-HTTPAuth%2Cversion_4.8.1%2Csummary_HTTP%2Bauthentication%2Bfor%2BFlask%2Broutes%2Clicense_MIT%2BLicense%2Cp_Ii9wYWNrYWdlcy9GbGFzay1IVFRQQXV0aCI%2Cs_0C8dL8w89UuL3Jfn.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Flask-HTTPAuth 4.8.1"
  "twitter:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_Flask-HTTPAuth%2Cversion_4.8.1%2Csummary_HTTP%2Bauthentication%2Bfor%2BFlask%2Broutes%2Clicense_MIT%2BLicense%2Cp_Ii9wYWNrYWdlcy9GbGFzay1IVFRQQXV0aCI%2Cs_0C8dL8w89UuL3Jfn.png"
---

> Index of every page on this site: [llms.txt](https://pypx.app/llms.txt)

# **Flask-HTTPAuth**

v4.8.1

HTTP authentication for Flask routes

9 KBpy3-none-anyMIT License1 deps

[** Diff **](https://pypx.app/packages/Flask-HTTPAuth/diff)

`$ uv add Flask-HTTPAuth`

# Flask-HTTPAuth

[![Build status](https://github.com/miguelgrinberg/Flask-HTTPAuth/workflows/build/badge.svg)](https://github.com/miguelgrinberg/Flask-HTTPAuth/actions) [![codecov](https://codecov.io/gh/miguelgrinberg/Flask-HTTPAuth/branch/master/graph/badge.svg?token=KeU2002DHo)](https://codecov.io/gh/miguelgrinberg/Flask-HTTPAuth)

Simple extension that provides Basic, Digest and Token HTTP authentication for Flask routes.

## Installation

The easiest way to install this is through pip.

```
pip install Flask-HTTPAuth
```

## Basic authentication example

```
from flask import Flask
from flask_httpauth import HTTPBasicAuth
from werkzeug.security import generate_password_hash, check_password_hash

app = Flask(__name__)
auth = HTTPBasicAuth()

users = {
    "john": generate_password_hash("hello"),
    "susan": generate_password_hash("bye")
}

@auth.verify_password
def verify_password(username, password):
    if username in users and \
            check_password_hash(users.get(username), password):
        return username

@app.route('/')
@auth.login_required
def index():
    return "Hello, %s!" % auth.current_user()

if __name__ == '__main__':
    app.run()
```

Note: See the [documentation](https://flask-httpauth.readthedocs.io/) for more complex examples that involve password hashing and custom verification callbacks.

## Digest authentication example

```
from flask import Flask
from flask_httpauth import HTTPDigestAuth

app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret key here'
auth = HTTPDigestAuth()

users = {
    "john": "hello",
    "susan": "bye"
}

@auth.get_password
def get_pw(username):
    if username in users:
        return users.get(username)
    return None

@app.route('/')
@auth.login_required
def index():
    return "Hello, %s!" % auth.username()

if __name__ == '__main__':
    app.run()
```

## Resources

- [Documentation](http://flask-httpauth.readthedocs.io/en/latest/)
- [PyPI](https://pypi.org/project/Flask-HTTPAuth)
- [Change log](https://github.com/miguelgrinberg/Flask-HTTPAuth/blob/main/CHANGES.md)

## **Details **

<dl>

<dt>Version</dt>
<dd>4.8.1</dd>

<dt>License</dt>
<dd>MIT License</dd>

<dt>Maintainer</dt>
<dd>Miguel Grinberg &lt;miguel.grinberg@gmail.com&gt;</dd></dl>

## **Links**

- [Bug Tracker](https://github.com/miguelgrinberg/flask-httpauth/issues)
- [Homepage](https://github.com/miguelgrinberg/flask-httpauth)
- [View on PyPI](https://pypi.org/project/Flask-HTTPAuth/)

## **Release Cadence **

**1**

releases in the past year

avg 136 days between releases

## **Maintainers **

- Miguel Grinberg · [miguel.grinberg@gmail.com](mailto:miguel.grinberg@gmail.com)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://pypx.app/#website","@type":"WebSite","description":"The Python Package Index, reimagined. Fast search, dependency insights, download trends, and changelogs — all in one place.","name":"pypx","url":"https://pypx.app/"},{"@id":"https://pypx.app/packages/flask-httpauth#webpage","@type":"WebPage","description":"HTTP authentication for Flask routes","name":"Flask-HTTPAuth","url":"https://pypx.app/packages/flask-httpauth","isPartOf":{"@id":"https://pypx.app/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://pypx.app/packages/flask-httpauth"]}]},{"@id":"https://pypx.app/packages/flask-httpauth#/schema/software-application/1","@type":"SoftwareApplication","applicationCategory":"DeveloperApplication","description":"HTTP authentication for Flask routes","license":"MIT License","name":"Flask-HTTPAuth","softwareVersion":"4.8.1"}]}
```

## Sitemap

See the full [sitemap](https://pypx.app/sitemap.md) for all pages.
