Spaces:
Running
Running
File size: 469 Bytes
aa27d2d 67264dd aa27d2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 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 |