Implement token based authentication using Flask and test APIs using Postman.
- Python
- Flask
- JWT (PyJWT)
- Postman
Endpoint: /auth-header
Method: GET
Authentication using Basic Authorization Header.
Endpoint: /custom-header
Method: GET
Authentication using custom headers.
Headers used:
X-Username
X-Password
Generate Token
Endpoint: /login
Method: POST
Body: { "username":"admin", "password":"1234" }
Access Protected Route
Endpoint: /jwt-protected
Method: GET
Header: Authorization : Bearer TOKEN
- Install dependencies
pip install flask pyjwt
- Run server
python app.py
Server runs at: