Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
AuthUser
✓ from quart_auth import AuthUser
✗ from quart.ext.auth import AuthUser
quart_auth is a separate package, not part of Quart core.
current_user
✓ from quart_auth import current_user
✗ from quart import current_user
current_user is not provided by Quart itself.
login_user
✓ from quart_auth import login_user
✗ from quart import login_user
login_user is specific to quart-auth.
QuartAuth
✓ from quart_auth import QuartAuth
✗ from quart_auth import QuartAuthManager
The class is named QuartAuth, not QuartAuthManager.
Minimal Quart app with cookie authentication using quart-auth.
from quart import Quart, redirect, request, url_for
from quart_auth import AuthUser, QuartAuth, current_user, login_required, login_user, logout_user
app = Quart(__name__)
app.secret_key = 'change-me-123'
auth_manager = QuartAuth(app)
@app.route('/login')
async def login():
user = AuthUser(1) # Replace 1 with actual user ID
login_user(user)
return redirect(url_for('protected'))
@app.route('/protected')
@login_required
async def protected():
return f'Hello {current_user.auth_id}'
@app.route('/logout')
async def logout():
logout_user()
return 'Logged out'
if __name__ == '__main__':
app.run()
Errors
Common errors & fixes
RuntimeError: No such config: 'QUART_AUTH_COOKIE_NAME'
Trying to set config keys that do not exist (typo or wrong name). The correct config key includes prefix 'QUART_AUTH_'.
fixCheck the config name exactly; e.g., use `app.config['QUART_AUTH_COOKIE_NAME'] = 'mycookie'`.
AttributeError: module 'quart_auth' has no attribute 'current_user'
Import incorrect: using `from quart_auth import current_user` but misspelled or imported from wrong module.
fixEnsure the import is `from quart_auth import current_user`.
TypeError: __init__() got an unexpected keyword argument 'name'
Old code using `AuthUser(id, name='...')`; newer versions only accept positional `auth_id`.
fixUse `AuthUser(auth_id)` only. Retrieve user details via a separate call.
Upgrade
Version history
0.11.0latest on PyPI · released Dec 26, 2024
Audit
Dependencies
quartrequiredCore framework
Resources
No resource links recorded.