https://github.com/jtemporal/minimal-fastapi-api-auth0
https://github.com/jtemporal/minimal-fastapi-api-auth0
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/jtemporal/minimal-fastapi-api-auth0
- Owner: jtemporal
- Created: 2025-05-17T15:35:41.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-17T16:09:05.000Z (about 1 year ago)
- Last Synced: 2025-06-22T04:02:36.591Z (12 months ago)
- Language: Python
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FastAPI Demo API with Auth0
This application is a sample on how to integrate Auth0 for authentication in a FastAPI API using APIRouter and module separation.
## How to run the API
1. Clone this repository
```
git clone https://github.com/jtemporal/minimal-fastapi-api-auth0.git && cd minimal-fastapi-api-auth0
```
2. Create a `.config` file from `.config.example` and populate the values from your Auth0 Application.
```
cp .config.example .config
```
Tip: you can use `openssl rand -hex 32` for the secret key.
3. Create a virtual environment and install dependencies
```
# Create a venv
python3 -m venv .env
# Activate
source .env/bin/activate
# Install dependencies
pip install -r requirements.txt
```
4. Start the server
```
uvicorn src.main:app --reload
```
## Making requests to the API
### Call a public endpoint
```sh
curl -X GET http://localhost:8000/api/public
```
### Call a private endpoint
```sh
curl -X GET http://localhost:8000/api/private
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
### Call a private endpoint with scopes
```sh
curl -X GET http://localhost:8000/api/private-scoped
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
----
Where to find me:
* [Jess' Socials](https://jtemporal.com/socials).
[Sign up for Auth0's developer newsletter here](https://a0.to/nl-signup/python).