Generate JWT token using Data Action Integration

Hi ,

Just wondering if anyone can help. We have a customer want to integrate their CRM (Momentus) into Genesys Cloud. And to call API of momentus, need to generate JWT token.

They give us snippet code to generate JWT token as following:

    function constructJWT(apiUserId, apiUserKey, apiUserSecret) {
        const header = { "alg": "HS256", "typ": "JWT" };

        const claimSet =
        {
            "iss": apiUserId,
            "key": apiUserKey,
            "exp": (KJUR.jws.IntDate.get("now") + 60).toString(), 
            //Adds 60 seconds expiration to the Unix Epoch time
            "iat": KJUR.jws.IntDate.get("now").toString()
        }

        ***var jwt = KJUR.jws.JWS.sign(null, header, claimSet, apiUserSecret);***

        console.log('jwt is ' + jwt);

        return jwt;

And once we get JWT, we can call API Momentus normally using JWT:

            type: method,
            url: ungerboeckApiUrl, //Make sure you pick an endpoint the API User is allowed to access
            headers: {
                **'Authorization': 'Bearer ' + jwt,**
                'Content-Type': 'application/json'
            },

Just wondering is there any way in Data Action to generate JWT token (constructJWT), can we implement this in Data Action Integration ?

Appreciate for any advise.

Fransiska

Hi Fransiska,

Data acton authentication and credential types currently do not support a generic JWT. We have worked with JWT for Google and Adobe authentication and that experience showed us that the vendor implementation were veried enough that we could not make a general mechanism that would handle the claims and Bearer veriations well enough to be common code.

Using a Lambda based Action with the JWT authentication in the Lambda and credentials to do the JWT signing being passed to your Lambda on invocation would likely be the best solution.

1 Like

Hi @Greg_Cunningham ,

Thanks for the advise, this will help us to advise the customer accordingly.

Just wondering with AWS lambda, means we need to create a Lambda externally, to generate JWT token and might also retrieve CRM data through their API in the lambda, and then hook that lambda into Genesys Cloud Data Action isnt it ?

Thank you
Fransiska

Just wondering with AWS lambda, means we need to create a Lambda externally, to generate JWT token and might also retrieve CRM data through their API in the lambda, and then hook that lambda into Genesys Cloud Data Action isnt it ?

That is correct.

Along with the option of using an AWS Lambda:

We also have an integration for Google Functions:
About the Google data actions integration - Genesys Cloud Resource Center.

--Jason

hi @Jason_Mathison ,,

Thanks for explanation, yes I understood now.
Will inform customer accordingly.

Fransiska

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.