{"id":21714,"library":"propelauth-fastapi","title":"PropelAuth FastAPI","description":"A FastAPI library for managing authentication, backed by PropelAuth. Current version is 4.4.0, requires Python >=3.9. Regularly updated with new APIs and improvements.","status":"active","version":"4.4.0","language":"python","source_language":"en","source_url":"https://github.com/propelauth/propelauth-fastapi","tags":["authentication","fastapi","propelauth"],"install":[{"cmd":"pip install propelauth-fastapi","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for building FastAPI applications","package":"fastapi","optional":false},{"reason":"Core PropelAuth Python SDK","package":"propelauth-py","optional":false}],"imports":[{"note":"Older versions used a different package path.","wrong":"from propelauth import PropelAuth","symbol":"PropelAuth","correct":"from propelauth_fastapi import PropelAuth"},{"note":"Common mistake, imports must come from propelauth_fastapi.","wrong":"from propelauth import get_user","symbol":"get_user","correct":"from propelauth_fastapi import get_user"}],"quickstart":{"code":"from fastapi import FastAPI, Depends\nfrom propelauth_fastapi import PropelAuth, get_user\n\napp = FastAPI()\n\nauth = PropelAuth(\n    auth_url=\"https://your-tenant.auth.us.authok.io\",\n    api_key=\"your-api-key\"\n)\n\n@app.get(\"/protected\")\nasync def protected_route(user = Depends(auth.require_user)):\n    return {\"message\": f\"Hello {user.email}\"}\n\n@app.get(\"/current-user\")\nasync def current_user(user = Depends(get_user)):\n    return user\n","lang":"python","description":"Initialize PropelAuth with your tenant credentials and protect routes using require_user dependency."},"warnings":[{"fix":"Replace PropelAuthConfig(...) with PropelAuth(auth_url=..., api_key=...).","message":"In v4.0.0, the library was rewritten to depend on propelauth-py. The initialization API changed: now pass auth_url and api_key directly instead of using PropelAuthConfig.","severity":"breaking","affected_versions":"<4.0.0"},{"fix":"Replace Depends(get_user) with Depends(auth.require_user).","message":"The get_user dependency is deprecated as of v4.4.0. Use require_user or the new user retrieval methods.","severity":"deprecated","affected_versions":">=4.4.0"},{"fix":"Ensure auth_url is a valid URL string starting with https://.","message":"The auth_url must include the full URL with tenant subdomain, e.g., 'https://your-tenant.auth.us.authok.io'. Missing 'https://' or the tenant part will cause cryptic authentication errors.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'pip install propelauth-fastapi' and ensure import is 'from propelauth_fastapi import PropelAuth'.","cause":"The package is not installed or imported incorrectly.","error":"ModuleNotFoundError: No module named 'propelauth_fastapi'"},{"fix":"Initialize with PropelAuth(auth_url='https://your-tenant.auth.us.authok.io', api_key='your-api-key').","cause":"PropelAuth() was called without required arguments.","error":"TypeError: __init__() missing 2 required positional arguments: 'auth_url' and 'api_key'"},{"fix":"Verify your API key and auth_url from the PropelAuth dashboard.","cause":"The API key is incorrect or the auth_url does not match the tenant.","error":"propelauth.errors.InvalidAPIKeyError: Invalid API key"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}