bookmyservice-ums / scripts /generate_token.py
MukeshKapoor25's picture
refactor(jwt): unify jwt configuration and token expiration handling
975cfc8
raw
history blame
648 Bytes
import sys
from pathlib import Path
from jose import jwt
from datetime import datetime, timedelta, timezone
# Ensure project root is importable so 'app' package resolves correctly
ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from app.core.config import settings
def main():
payload = {
"sub": "test-customer-123",
"exp": datetime.now(timezone.utc) + timedelta(minutes=settings.JWT_ACCESS_TOKEN_EXPIRE_MINUTES),
}
token = jwt.encode(payload, settings.JWT_SECRET_KEY, algorithm=settings.JWT_ALGORITHM)
print(token)
if __name__ == "__main__":
main()