create_access_token
Generates a JSON Web Token (JWT) for a given subject that expires after a specified time duration using a secret key and predefined algorithm.
def create_access_token(
subject: str | Any,
expires_delta: timedelta
) - > string
Generates a signed JSON Web Token (JWT) for a specific subject that expires after a designated time interval. Use this to provide secure, time-limited authentication credentials for users or services.
Parameters
| Name | Type | Description |
|---|---|---|
| subject | `str | Any` |
| expires_delta | timedelta | The duration from the current UTC time until the token becomes invalid. |
Returns
| Type | Description |
|---|---|
string | A base64-encoded JWT string containing the subject and expiration claims, signed with the application's secret key. |