Created
February 16, 2019 13:46
-
-
Save respondcreate/0b6313eaac87c0d854a0b42aa0fe35bc to your computer and use it in GitHub Desktop.
PyJWT RS256 Okta Access Token Local Validation Example
This file contains 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
"""How to validate Okta Access Tokens Locally with Python""" | |
import jwt | |
from jwt.algorithms import RSAAlgorithm | |
# Key pulled from https://{example}.oktapreview.com/oauth2/{client-id}/v1/keys | |
key_json = '{"kty":"RSA","alg":"RS256","kid":"your-kid-value-here","use":"sig","e":"AQAB","n":"your-long-key-here"}' | |
aud = "your-audience-value-here" | |
token_to_validate = "your-access-token-value-here" | |
public_key = RSAAlgorithm.from_jwk(key_json) | |
decoded = jwt.decode(token_to_validate, public_key, audience=aud, algorithms='RS256') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment