Last active
February 16, 2018 02:31
-
-
Save zaguiini/246329a7bb00d467650689ed2e65d7f5 to your computer and use it in GitHub Desktop.
A simple JWT verification 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 | |
secret = 'minha_super_chave_imprevisivel' | |
meu_jwt = request['headers']['authorization'] | |
try: | |
informacoes = jwt.decode(meu_jwt, secret, algorithm='HS256') | |
except ExpiredSignatureError: | |
print('Seu token esta expirado!') | |
except DecodeError: | |
print('Token invalido ou segredo incorreto!') | |
except: | |
print('Outro erro!') | |
else: | |
print(informacoes['uid']) # 123 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment