Read the story in this [Medium post: Bearer Token Authentication]
(https://medium.com/@hitorunajp/bearer-token-authentication-0bade60aa2cb)
Create a env like
$ python3 -m venv MyEnv
$ soure MyEnv/bin/activateand then
$ pip install -r myapp/requirements.txt]
$ cd myapp
$ uvicorn main:app --reloadwith that try it with
$ curl -L http://localhost:8000/
{"message":"This endpoint is public"}
$ curl -L http://localhost:8000/secure
{"detail":"Missing or invalid Authorization header"}
$ curl -L -H "Authorization: Bearer my-secret-token" http://localhost:8000/secure
{"message":"This is a protected endpoint"}
$ curl -L http://localhost:8000/secure2
{"detail":"Not authenticated"}
$ curl -L -H "Authorization: Bearer my-secret-token" http://localhost:8000/secure2
{"message":"This is another protected endpoint!"}
The secure2 endpoint works with Swagger