okta-jwt-verifier-python icon indicating copy to clipboard operation
okta-jwt-verifier-python copied to clipboard

Decoding JWT

Open akcode47 opened this issue 2 years ago • 0 comments

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

akcode47 avatar Apr 24 '23 00:04 akcode47