Spotix-API / backend /app /utils /jwt_handler.py
Anish
[UI/UX] Features and good animations added
67264dd
from datetime import datetime, timedelta, UTC
from jose import jwt
from app.core.config import settings
ALGORITHM = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES = 43200 # 30 Days
def create_access_token(data: dict):
to_encode = data.copy()
expire = datetime.now(UTC) + timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)
to_encode.update({"exp": expire})
encoded_jwt = jwt.encode(to_encode, settings.JWT_SECRET, algorithm=ALGORITHM)
return encoded_jwt