Legacy Dev Forum Posts

 View Only

Sign Up

Auth Menssager Send Custon Fields at AuthProvider.registerCommand('getAuthCode'

  • 1.  Auth Menssager Send Custon Fields at AuthProvider.registerCommand('getAuthCode'

    Posted 06-05-2025 18:36

    LucasArrudaFernand | 2022-11-30 13:36:15 UTC | #1

    Hi,

    This guide (https://developer.genesys.cloud/commdigital/digital/webmessaging/messengersdk/authenticatedMessenger) tells to use the AuthProvider.registerCommand('getAuthCode' ... function to accomplish the step 6 of the image under "Authenticated web message flow" at link https://developer.genesys.cloud/commdigital/digital/webmessaging/authenticate#authenticated-web-message-flow

    The problem I am facing is that my auth server (auth0) needs additional parameters, other than:

    authCode: <brand auth code>, // pass your authorization code here redirectUri: <your redirect uri>, // pass the redirection URI configured in your Authentication provider here nonce: <your nonce>, // pass the random string preferably in uuid format. Applicable for OKTA provider. maxAge: <your maxAge>, // pass elapsed time in seconds. Applicable for OKTA provider and it is an optional parameter. codeVerifier: <your code verifier> // pass your code verifier here when PKCE flow is enabled iss: <your iss>, // pass your iss here. It is an optional parameter provided in the authorization response by your Authentication provider.

    I need to add userid and username fields,

    See here one Sucess Authorization Code for Access Token generated with my auth server:

    { "date": "2022-11-29T22:03:06.975Z", "type": "seacft", "description": "Authorization Code for Access Token", "connectionid": "", "clientid": "JKZ6L20wpOI4qWX2kswEahAoytXPErsD", "clientname": "My App", "ip": "177.86.98.167", "useragent": "Other 0.0.0 / Other 0.0.0", "details": { "code": "**************OnG" }, "hostname": "dev-qddc8snapx3463gm.us.auth0.com", "userid": "auth0|6384d1eece5082a502e060e6", "username": "lukaarruda@hotmail.com", "auth0client": { "name": "express-oidc", "version": "2.10.0", "env": { "node": "v16.14.1" } }, "logid": "90020221129220311992170765555527241006091813296172695570", "_id": "90020221129220311992170765555527241006091813296172695570", "isMobile": false, "id": "90020221129220311992170765555527241006091813296172695570" }

    See here the failed attempt made from Genesys plugin (AuthProvider.registerCommand('getAuthCode' ...):

    { "date": "2022-11-29T22:03:29.333Z", "type": "feacft", "description": "Invalid authorization code", "connectionid": "", "clientid": "JKZ6L20wpOI4qWX2kswEahAoytXPErsD", "clientname": "My App", "ip": "52.40.250.127", "useragent": "Other 0.0.0 / Other 0.0.0", "details": { "code": "**************OnG" }, "hostname": "dev-qddc8snapx3463gm.us.auth0.com", "userid": "", "username": "", "logid": "90020221129220333234030845274560395248984397663426314242", "id": "90020221129220333234030845274560395248984397663426314242", "isMobile": true, "id": "90020221129220333234030845274560395248984397663426314242" }

    I tried adding those custom parameters in the server code:

    // COMMAND // ***** // getAuthCode // reAuthenticate /* Register Command - mandatory */

    AuthProvider.registerCommand('getAuthCode', (e) => { // Add the necessary logic and resolve with the authCode and redirectUri provided by your Authentication provider. Messenger will call this command to get the the tokens. e.resolve({ authCode: authCode, redirectUri: 'https://lucasarruda.ml:3000/profile', userid: "auth0|6384d1eece5082a502e060e6", username: "lukaarruda@hotmail.com" }); });

    But what I see it that those additional ones are not sent to Genesys Platform, see here what I can see on user browser network log being sent:

    Request URL: https://api.usw2.pure.cloud/api/v2/webdeployments/token/oauthcodegrantjwtexchange

    Payload: {"deploymentId":"29015b77-2699-4a95-8d8a-33cadd6919de","oauth":{"code":"KQZlhQs8nAqEyDtD24LfuvFCO00pAWF0pYswddCnbjOnG","redirectUri":"https://lucasarruda.ml:3000/profile"},"journeyContext":{"customer":{"id":"31342340-537e-450b-8b16-995938c34e04","idType":"cookie"},"customerSession":{"id":"f9cb4b45-27e8-433f-ac21-7690d24c8fd7","type":"web"}}}

    Please advise if is possible to add those two custom fields (userid, username) on this step 6 (see 2nd link sent on this case description, here again for easy reference: https://developer.genesys.cloud/commdigital/digital/webmessaging/authenticate#authenticated-web-message-flow)


    vpirat | 2022-12-02 14:16:21 UTC | #2

    Hi, Web messaging is implementing OpenId protocol. I see that auth0 is also compliant with OpenId so parameters you me ntion should not be required. Have you declared your app as an openID one ? See https://auth0.com/docs/authenticate/protocols/openid-connect-protocol

    You can retrieve userid and username from openId once logged in (sub and name claims). See https://auth0.com/docs/get-started/apis/scopes/openid-connect-scopes

    Hope this helps, Let me know if any further questions.

    Best regards, V.P.


    system | 2023-01-01 14:16:56 UTC | #3

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


    This post was migrated from the old Developer Forum.

    ref: 17437