Skip to content

KansaiUser/Bearer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Beared Token Authentication

Read the story in this [Medium post: Bearer Token Authentication]

To use

(https://medium.com/@hitorunajp/bearer-token-authentication-0bade60aa2cb)

Create a env like

$ python3 -m venv MyEnv
$ soure MyEnv/bin/activate

and then

$ pip install -r myapp/requirements.txt]
$ cd myapp
$ uvicorn main:app --reload

with 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages