visus-plus/api/app/infrastructure/auth_service.py

15 lines
421 B
Python

import datetime
from jose import jwt
from app.settings import get_auth_data
def create_access_token(data: dict) -> str:
to_encode = data.copy()
expire = datetime.now(datetime.timezone.utc) + datetime.timedelta(days=30)
to_encode.update({"exp": expire})
auth_data = get_auth_data()
encode_jwt = jwt.encode(to_encode, auth_data['secret_key'], algorithm=auth_data['algorithm'])
return encode_jwt