okta / okta-jwt-verifier-python

okta-jwt-verifier-python
https://github.com/okta/okta-jwt-verifier-python
Apache License 2.0
33 stars 17 forks source link

Decoding JWT #49

Open akcode47 opened 1 year ago

akcode47 commented 1 year ago

This is not an issue but a suggestion for decoding a JWT (hopefully, it helps):

The readme example shows how to use AccessTokenVerifier to validate an access token. However, if you want to use the claims/sub information within the payload for further user verification, you must decode the JWT.

To decode, you don't need to add PyJWT - the library has a built-in parser leveraging python-jose. To use it, import the following:

from okta_jwt_verifier import AccessTokenVerifier, JWTUtils
....
try:
    await jwt_verifier.verify(access_token)
    headers, claims, signing_input, signature = JWTUtils.parse_token(access_token)
    # claims will be a dictionary that contains information like the 'sub' key