To register a new user, send a POST request to /register
with the following JSON data:
{ "username": "your_username", "email": "your_email", "password": "your_password" }Example: curl -X POST http://localhost:5000/register -H "Content-Type: application/json" -d '{"username": "example", "email": "example@example.com", "password": "example123"}'
To log in, send a POST request to /login
with the JSON data containing your username and password:
{ "username": "your_username", "password": "your_password" }
You will receive a JWT token in the response. Copy this token to use in the next step.
To access the protected resource, send a GET request to /protected
with the JWT token in the Authorization
header:
Authorization: Bearer your_jwt_token
curl -X GET http://localhost:5000/protected -H "Authorization: Bearer your_jwt_token"
Remember to replace your_username
, your_password
, and your_jwt_token
with actual values.