add expiry to jwt extended token 1

add expiry to jwt extended token

def create_dev_token():
    username = get_jwt_identity()
    expires = datetime.timedelta(days=365)
    token = create_access_token(username, expires_delta=expires)
    return jsonify({'token': token}), 201

Here is what the above code is Doing:
1. The @jwt_required decorator will make sure that the user is authenticated before calling the create_dev_token() function.
2. The get_jwt_identity() function will return the identity of the user.
3. The create_access_token() function will create a new access token.
4. The jsonify() function will create a JSON response.
5. The 201 status code will be returned to indicate that the token was created successfully.

Similar Posts