21 lines
496 B
Python
21 lines
496 B
Python
from jose import JWTError, jwt
|
|
import os
|
|
import werkzeug
|
|
|
|
|
|
JWT_SECRET = os.environ['JWT_SECRET']
|
|
|
|
def decodeToken(token):
|
|
try:
|
|
return jwt.decode(token, JWT_SECRET)
|
|
except JWTError as e:
|
|
print("ERROR: decodeToken: {}".format(e))
|
|
raise werkzeug.exceptions.Unauthorized()
|
|
|
|
def getSecret(user, token_info):
|
|
return '''
|
|
You are user_id {user} and the secret is 'wbevuec'.
|
|
Decoded token claims: {token_info}.
|
|
'''.format(user=user, token_info=token_info)
|
|
|