Skip to content

Instantly share code, notes, and snippets.

@nmcspadden
Created October 19, 2016 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmcspadden/1a66b0dfa7e19a181957ef8b115a1296 to your computer and use it in GitHub Desktop.
Save nmcspadden/1a66b0dfa7e19a181957ef8b115a1296 to your computer and use it in GitHub Desktop.
adobe_tools - Prepare JWT
def prepare_jwt_token(config_data, priv_key):
"""Construct the JSON Web Token for auth."""
# set expiry time for JSON Web Token
expiry_time = int(time.time()) + 60 * 60 * 24
# create payload
payload = {
"exp": expiry_time,
"iss": config_data['org_id'],
"sub": config_data['tech_acct'],
"aud": "https://" + config_data['ims_host'] + "/c/" +
config_data['api_key'],
"https://" + config_data['ims_host'] + "/s/" + "ent_user_sdk": True
}
# create JSON Web Token
jwt_token = jwt.encode(payload, priv_key, algorithm='RS256')
# decode bytes into string
jwt_token = jwt_token.decode("utf-8")
return jwt_token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment