Spaces:
Sleeping
Sleeping
Download scripts/generate_token.py from bmsadmin/bookmyservice-ums: direct link, hf CLI and curl.
- Browser
- Download file 648 Bytes
-
https://huggingface.co/spaces/bmsadmin/bookmyservice-ums/resolve/main/scripts/generate_token.py
- Command line
-
hf download hf://spaces/bmsadmin/bookmyservice-ums/scripts/generate_token.py
-
curl -L -o generate_token.py https://huggingface.co/spaces/bmsadmin/bookmyservice-ums/resolve/main/scripts/generate_token.py
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() |