Skip to content

Instantly share code, notes, and snippets.

@abhaybhargav
Created November 10, 2016 04:41
Show Gist options
  • Save abhaybhargav/9417c6f11cda296598ddbebdfc5ab1a5 to your computer and use it in GitHub Desktop.
Save abhaybhargav/9417c6f11cda296598ddbebdfc5ab1a5 to your computer and use it in GitHub Desktop.
Validating the JWT
def verify_jwt(token):
try:
decoded = jwt.decode(token, app.config['SECRET_KEY_HMAC'], verify=True, issuer = 'we45', leeway=10, algorithms=['HS256'])
print("JWT Token from API: {0}".format(decoded))
return True
except DecodeError:
print("Error in decoding token")
return False
except MissingRequiredClaimError as e:
print('Claim required is missing: {0}'.format(e))
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment