Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save respondcreate/0b6313eaac87c0d854a0b42aa0fe35bc to your computer and use it in GitHub Desktop.
Save respondcreate/0b6313eaac87c0d854a0b42aa0fe35bc to your computer and use it in GitHub Desktop.
PyJWT RS256 Okta Access Token Local Validation Example
"""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