def __prepare_jwt_token()

in legacy/adobe_tools/adobe_api.py [0:0]


    def __prepare_jwt_token(self):
        """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": self.configs['org_id'],
            "sub": self.configs['tech_acct'],
            "aud": (
                "https://" +
                self.configs['ims_host'] +
                "/c/" +
                self.configs['api_key']
            ),
            (
                "https://" +
                self.configs['ims_host'] +
                "/s/" +
                "ent_user_sdk"
            ): True
        }
        # create JSON Web Token
        jwt_token = jwt.encode(payload, self.priv_key, algorithm='RS256')
        # decode bytes into string
        jwt_token = jwt_token.decode("utf-8")
        return jwt_token