Closed silvanohirtie closed 3 years ago
How can I set how much a token lasts? For now, I can use one just for a couple of minutes, 10 or maybe 20, but then it gets unavailable.
https://indominusbyte.github.io/fastapi-jwt-auth/configuration/general/
authjwt_access_token_expires
How long an access token should live before it expires. This takes value integer (seconds) or datetime.timedelta, and defaults to 15 minutes. Can be set to False to disable expiration.
authjwt_refresh_token_expires
How long an refresh token should live before it expires. This takes value integer (seconds) or datetime.timedelta, and defaults to 30 days. Can be set to False to disable expiration.
@brunohenriquy an example on how to use it? I need to define it when I create the token or like it's a setting i can define at the top of the file? I'm creating the jwt like this: access_token = Authorize.create_access_token(subject="testUser")
@brunohenriquy an example on how to use it? I need to define it when I create the token or like it's a setting i can define at the top of the file? I'm creating the jwt like this: access_token =
Authorize.create_access_token(subject="testUser")
It's a setting, if you are using a single file only for trying the lib, check this example here: https://indominusbyte.github.io/fastapi-jwt-auth/usage/basic/
You can do:
class Settings(BaseModel):
authjwt_secret_key: str = "secret"
authjwt_access_token_expires = 1800 # It's in seconds, so it will be 30 minutes
authjwt_refresh_token_expires = 86400 # It's in seconds, so it will be 24 hours
oh clear now, thanks!!
How can I set how much a token lasts? For now, I can use one just for a couple of minutes, 10 or maybe 20, but then it gets unavailable.