-
-
Save nmcspadden/1a66b0dfa7e19a181957ef8b115a1296 to your computer and use it in GitHub Desktop.
adobe_tools - Prepare JWT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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