File size: 461 Bytes
478dec6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from config.constant import SecurityConstants
from datetime import datetime, timedelta
from jose import jwt


def create_access_token(data: dict) -> str:
    to_encode = data.copy()
    expire = datetime.now() + timedelta(
        minutes=SecurityConstants.JWT_EXPIRE_MINUTES
    )
    to_encode.update({"exp": expire})

    return jwt.encode(
        to_encode,
        SecurityConstants.JWT_SECRET_KEY,
        algorithm=SecurityConstants.JWT_ALGORITHM,
    )