This code is an example FARM (FastAPI, React, MongoDB) project with Authentication.
It was written to accompany the MongoDB developer article "Adding Authentication to your FARM Stack App". You should probably read that blog post before running the code here, but if you want to get started quickly short instructions are below.
Install into your currently active Python environment with:
python3 -m pip install -r requirements.txt
You'll need to set the following environment variables before running the project:
# The following will work on Linux & OSX:
export DEBUG_MODE=True
export DB_URL="mongodb+srv://<username>:<password>@<url>/farmstack?retryWrites=true&w=majority"
export JWT_SECRET_KEY="<secret value>"
export REALM_APP_ID="<realm id>"
Run the code with the following command:
uvicorn main:app --reload