Example app to easily add token-based authentication to your FastAPI applications. JWT tokens are a secure and efficient way to authenticate users in modern web applications.
- Clone the Repository:
git clone https://github.com/GabrielPy28/FastAPI-JWT.git
- In the terminal run comand:
> python
> import secrets
... secrets.token_hex(16)
- Configure environment variables
echo "SECRET_KEY = use your secret code with secrets.token_hex(16) here" >> .env
echo "ALGORITHM = HS256" >> .env
- Install requirements
pip install -r requirements.txt
- Run app:
uvicorn main:app --reload
Note
If everything is working correctly, the app is running on http://127.0.0.1:8000, to access all endpoints, go to http://127.0.0.1:8000/docs