Skip to content

Instantly share code, notes, and snippets.

@yalin
Created March 29, 2023 06:37
Show Gist options
  • Save yalin/be1b5b6309371ecef8b92b414511e410 to your computer and use it in GitHub Desktop.
Save yalin/be1b5b6309371ecef8b92b414511e410 to your computer and use it in GitHub Desktop.
import datetime
import os
import jwt
from dotenv import load_dotenv
load_dotenv() # take environment variables from .env.
secret_key = os.getenv("TOKEN_SECRET_KEY")
secret_name= os.getenv("TOKEN_SECRET_NAME")
payload = {
"sub": secret_name,
}
token = jwt.encode(payload, secret_key, algorithm="HS256")
print(token)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment