Skip to content

Commit 4f2c9f2

Browse files
committed
docs(examples): improve example docs and environment configuration
- Add a README section with ready-to-run examples, descriptions, and instructions for setting environment variables and executing them - Update the example login script to read the client ID from the AUTHGATE_CLIENT_ID environment variable instead of CLIENT_ID Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
1 parent 3cd7f84 commit 4f2c9f2

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,26 @@ def protected():
9898
return {"user": info.user_id}
9999
```
100100

101+
## Examples
102+
103+
Ready-to-run examples are in the [`examples/`](examples/) directory:
104+
105+
| File | Description |
106+
| --------------------------------------------------------------- | ----------------------------------------------------------------- |
107+
| [`01_user_login.py`](examples/01_user_login.py) | Interactive user login — auto-selects browser or device code flow |
108+
| [`02_client_credentials.py`](examples/02_client_credentials.py) | M2M service authentication with auto-cached tokens |
109+
| [`03_fastapi_server.py`](examples/03_fastapi_server.py) | FastAPI server with Bearer token validation and scope enforcement |
110+
| [`04_async_login.py`](examples/04_async_login.py) | Async user login via device code flow |
111+
112+
Set the required environment variables, then run with `uv`:
113+
114+
```bash
115+
export AUTHGATE_URL="https://auth.example.com"
116+
export AUTHGATE_CLIENT_ID="my-app"
117+
118+
uv run python examples/01_user_login.py
119+
```
120+
101121
## Development
102122

103123
```bash

examples/01_user_login.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import authgate
1515

1616
AUTHGATE_URL = os.environ["AUTHGATE_URL"]
17-
CLIENT_ID = os.environ["CLIENT_ID"]
17+
CLIENT_ID = os.environ["AUTHGATE_CLIENT_ID"]
1818

1919

2020
def main() -> None:

0 commit comments

Comments
 (0)