Created
March 16, 2020 09:28
-
-
Save cuongld2/50a2b4b743cfc63604fc54f01b7f5c56 to your computer and use it in GitHub Desktop.
create access token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_access_token(*, data: dict, expires_delta: timedelta = None): | |
secret_key = "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7" | |
algorithm = "HS256" | |
to_encode = data.copy() | |
if expires_delta: | |
expire = datetime.utcnow() + expires_delta | |
else: | |
expire = datetime.utcnow() + timedelta(minutes=15) | |
to_encode.update({"exp": expire}) | |
encoded_jwt = jwt.encode(to_encode, secret_key, algorithm=algorithm) | |
return encoded_jwt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment