Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Generates, verifies, and decodes JWT access tokens and extracts current users for FastAPI and Python apps.
32% 86%+55 ptsof test cases passed
Passed 19 of 22 test cases with the skill, and 7 of 22 without it.
3 of 3 safety checks passed
Not used yet
Expert implementation of JWT token generation, verification, and user extraction for FastAPI and Python applications.
| Operation | Function | Location |
|---|---|---|
| Generate token | create_access_token(data, expires_delta=None) | auth/jwt.py |
| Verify token | verify_token(token: str) | auth/dependencies.py |
| Get current user | get_current_user(token: str) | auth/dependencies.py |
| User from payload | User.from_payload(payload) | auth/dependencies.py |
from auth.jwt import create_access_token
# Basic token with subject
token = create_access_token(data={"sub": "[email protected]"})
# Token with custom expiry (minutes)
from datetime import timedelta
token = create_access_token(
data={"sub": "[email protected]", "roles": ["admin"]},
expires_delta=timedelta(minutes=15)
)
# Token with roles for RBAC
token = create_access_token(data={"sub": "[email protected]", "roles": ["editor", "viewer"]})
Claims structure:
sub (required): User identifier (email, ID, or username)exp (auto): Expiration timeroles (optional): List of role strings for authorizationSkills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus popular skills in the same category.