Last active
February 16, 2018 02:04
-
-
Save zaguiini/a5957d3a77b6be0b5dfc3046262fc03f to your computer and use it in GitHub Desktop.
A simple JWT generation snippet
This file contains hidden or 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
import jwt | |
from time import time # para geracao da timestamp | |
secret = 'minha_super_chave_imprevisivel' | |
user_id = 123 | |
payload = { | |
'uid': user_id, | |
'exp': int(time()) + 3600 # queremos que o token seja valido por uma hora | |
} | |
meu_token_assinado = jwt.encode(payload, secret, algorithm='HS256') | |
# exemplo: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjEyMywiZXhwIjoxNTE4NzQ5OTg1fQ.-uUCFwVFhpg57Jig9VwWh86f85Uip4lPvF4iL6nxjbA |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment