Beispiel #1
0
def generate_jwt(email):
    claims = {
        'exp': datetime.datetime.now() + datetime.timedelta(days=1),
        'iss': 'toby',
        'user': email
    }
    token = jwt.encode(payload=claims,
                       key=Secret.get_secret('jwt'),
                       algorithm='HS256')
    return token
Beispiel #2
0
def verify_jwt(headers):
    token = get_token_from_header(headers)
    try:
        payload = jwt.decode(token,
                             Secret.get_secret('jwt'),
                             verify=True,
                             algorithms=['HS256'])
    except Exception as e:
        raise JWTError('Invalid Token: ' + str(e))

    return payload