Skip to content

Instantly share code, notes, and snippets.

@greene858
Created March 14, 2023 00:16
Show Gist options
  • Save greene858/aadd89f27ed0d50cb0581219d9733d3c to your computer and use it in GitHub Desktop.
Save greene858/aadd89f27ed0d50cb0581219d9733d3c to your computer and use it in GitHub Desktop.
import jwt
""" note this is the PyJWT lib
e.g. python3 -m pip import PyJWT
"""
EXPIRATION = 9999999999 #never expire
AUDIENCE = "mas_dev" #MAS test group
SCOPE = "openid vro_mas" #MAS test scope
KEY = "test_key" #mock key
ALGORITHM = "HS256" #algorithm use in VRO
KEY_ID = "test_key_id" #mock key ID
# encode JWT with payload and headers needed for end2end test
encoded = jwt.encode(
{
"exp": EXPIRATION,
"aud": AUDIENCE,
"scope": SCOPE
},
KEY,
algorithm=ALGORITHM,
headers={"alg": ALGORITHM, "kid": KEY_ID},
)
# output the encoded JWT
print(encoded)
# if the decoded value is needed it can be output with:
# decoded = jwt.decode(encoded, KEY, audience=AUDIENCE, algorithms=ALGORITHM)
# print(decoded)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment