MCPcopy Index your code
hub / github.com/fastapi-users/fastapi-users / generate_jwt

Function generate_jwt

fastapi_users/jwt.py:17–27  ·  view source on GitHub ↗
(
    data: dict,
    secret: SecretType,
    lifetime_seconds: int | None = None,
    algorithm: str = JWT_ALGORITHM,
)

Source from the content-addressed store, hash-verified

15
16
17def generate_jwt(
18 data: dict,
19 secret: SecretType,
20 lifetime_seconds: int | None = None,
21 algorithm: str = JWT_ALGORITHM,
22) -> str:
23 payload = data.copy()
24 if lifetime_seconds:
25 expire = datetime.now(timezone.utc) + timedelta(seconds=lifetime_seconds)
26 payload["exp"] = expire
27 return jwt.encode(payload, _get_secret_value(secret), algorithm=algorithm)
28
29
30def decode_jwt(

Callers 8

request_verifyMethod · 0.90
forgot_passwordMethod · 0.90
write_tokenMethod · 0.90
generate_state_tokenFunction · 0.90
_tokenFunction · 0.90
test_generate_decode_jwtFunction · 0.90
_verify_tokenFunction · 0.90
_forgot_password_tokenFunction · 0.90

Calls 1

_get_secret_valueFunction · 0.85

Tested by 4

_tokenFunction · 0.72
test_generate_decode_jwtFunction · 0.72
_verify_tokenFunction · 0.72
_forgot_password_tokenFunction · 0.72