This FastAPI API provides endpoints to validate JWT tokens from request headers.
-
Clone this repository:
git clone https://github.com/RashedulAlam/python-jwt-validation.git
-
Install the required dependencies:
pip install -r requirements.txt
To run the API locally, use the following command:
uvicorn app.main:app --reload
To run the API using Docker, build the Docker image:
docker build -t fastapi-jwt-validation .
docker run -d --name fastapi-jwt-validation -p 8000:80 fastapi-jwt-validation
Checks JWT token validity from the request header.
-
Parameters:
-
Returns:
valid
(bool): Whether the token is valid or not.reason
(str): Reason for token validation result.
Checks JWT token validity from the request header with additional options.
-
Parameters:
-
Returns:
valid
(bool): Whether the token is valid or not.reason
(str): Reason for token validation result.
GET /api/v1/check-jwt-validity
Authorization: Bearer <VALID_JWT_TOKEN>
{
"valid": true
}
GET /api/v1/check-jwt-validity
Authorization: Bearer <INVALID_JWT_TOKEN>
{
"valid": false,
"reason": "Invalid JWT signature"
}
GET /v1/check-jwt-validity
Authorization: Bearer <VALID_JWT_TOKEN>
{
"valid": false
}
GET /v1/check-jwt-validity
Authorization: Bearer <INVALID_JWT_TOKEN_INVALID_SIGNATURE>
{
"valid": false,
"reason": "Invalid JWT signature"
}