Legacy Dev Forum Posts

 View Only

Sign Up

Generate JWT token using Data Action Integration

  • 1.  Generate JWT token using Data Action Integration

    Posted 06-05-2025 18:45

    fransiska.hendra | 2024-01-31 04:39:37 UTC | #1

    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


    Greg_Cunningham | 2024-01-31 21:23:41 UTC | #2

    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.


    fransiska.hendra | 2024-01-31 22:00:39 UTC | #3

    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


    Jason_Mathison | 2024-02-04 03:17:22 UTC | #4

    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: https://help.mypurecloud.com/articles/about-the-aws-lambda-data-actions-integration/

    We also have an integration for Google Functions: https://help.mypurecloud.com/articles/about-the-google-data-actions-integration/#:~:text=The%20Google%20data%20actions%20integration%20allows%20you%20to%20create%20custom,on%20data%20in%20Google%20applications.

    --Jason


    fransiska.hendra | 2024-02-04 11:40:34 UTC | #5

    hi @Jason_Mathison ,,

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

    Fransiska


    system | 2024-03-06 11:40:35 UTC | #6

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


    This post was migrated from the old Developer Forum.

    ref: 24393