Skip to content

CLI

FastAuth ships a fastauth CLI built with Typer and Rich. Install with the cli extra.

pip install "sreekarnv-fastauth[cli]"

Commands

fastauth version

Prints the installed FastAuth version:

$ fastauth version
FastAuth v0.5.7

fastauth generate-secret

Prints a URL-safe random string suitable for FastAuthConfig.secret. HS256 requires ≥32 bytes — the default output (64 bytes) is well above the minimum.

$ fastauth generate-secret
q5N2x8...                                # 64 bytes by default

$ fastauth generate-secret --length 48
q5N2x8...                                # custom length
$ fastauth generate-secret -l 32         # minimum acceptable for HS256

Use it to populate secret in your config or .env.

fastauth check

Prints a table of every extra and whether the packages it provides are importable in the current environment. Useful when debugging MissingDependencyError.

$ fastauth check
FastAuth v0.5.7
...

fastauth providers

Lists the available OAuth providers and whether they are usable (the OAuth providers depend on the oauth extra → httpx).

$ fastauth providers
...

fastauth init [<output_dir>]

Scaffolds a runnable FastAuth app into output_dir (default .). Writes two files:

  • fastauth_config.py — a FastAuthConfig using SQLAlchemyAdapter(engine_url="sqlite+aiosqlite:///./auth.db") + CredentialsProvider().
  • main.py — a FastAPI app with an asynccontextmanager lifespan that calls adapter.create_tables() and auth.mount(app).

Use --force (-f) to overwrite existing files.

$ fastauth init my_app
Created: my_app/fastauth_config.py
Created: my_app/main.py
$ cd my_app && pip install "sreekarnv-fastauth[standard]" && uvicorn main:app --reload

fastauth requires the cli extra. If it is not installed, running the CLI prints a help message pointing to pip install sreekarnv-fastauth[cli]. (The typer and rich packages must be importable.)

Global

  • --help on any command shows usage.
  • no_args_is_help=True — running fastauth with no subcommand prints help.