Authenticated Web Messaging assistance

Hi, we are currently looking to use Authenticated Web Messaging for one of our customers. They are using Forgerock in conjunction with OpenID (which has been set up already) however they are getting an identity error when trying to run the authenticated web messaging code found here: https://developer.genesys.cloud/commdigital/digital/webmessaging/messengersdk/authenticatedMessenger

Error:

Request URL:

https://api.mypurecloud.com.au/api/v2/webdeployments/token/oauthcodegrantjwtexchange

Request payload:

{"deploymentId":"e578e735-7670-45fb-a337-be111658ab17","oauth":{"code":"lyZQje1zseU58mD1JhNEJBWSkqU","redirectUri":https://dev-api.telstrasuper.com.au/api/IdentityMgmt/openidconnect/getauthorisecode},"journeyContext":{"customer":{"id":"eaf332b5-2d60-4a58-835f-cc0ea8f2cae4","idType":"cookie"},"customerSession":{"id":"b60729b8-24ba-467d-9572-59c565f355e6","type":"web"}}}

Response payload:

{

"message": "Failed to identify user for token: 04dd016be93dc0ad47ac1da855e92fcc deploymentId: e578e735-7670-45fb-a337-be111658ab17",

"code": "unauthorized",

"status": 401,

"contextId": "eadb6e51-1629-4161-afac-9c393dc9f6c8",

"details": [],

"errors": []

}

I've attached an image of the code snippet used by the customer

Just wanting to know if anyone else has used Forgerock before for authentication and can spot if anything is missing?

Additionally the customer has provided these logs

Error message: "text": "{"message":"Failed to identify user for token: 2f24b602eb08bbxxxxxxxxxxxdeploymentId: e578e735-7670-45fb-a337-xxxxxxxxxx","code":"unauthorized","status":401,"contextId":"05583e59-4d14-4236-xxxxxxxxxxxx","details":[],"errors":[]}"

Hi Josh,

I'm not aware of any integration with ForgeRock but I could be wrong.

Regarding the issue, it occurs when exchanging the code with the auth server.
I could see the following error message:
invalid_client (Invalid authentication method for accessing this endpoint.)

So no issue in the snippet but some discrepancy in what is supported by the auth provider and what is used by the openid client.
For example, the client is configured for basic authentication, but client_id and client_secret are provided in the body of the request and NO Basic Authentication header was provided.

Can you check what is expecting the auth server ?
I do not have access to the customer config unfortunately.
Checking logs on auth server could help as well.

Let us know.

Best regards,
V.P.

Hey V.P.

Thanks for the update - we've configured the OpenID integration in their org with their discovery URI, client secret and client ID and I can see that it matches to their configuration within forgerock - I will go back to customer and get the logs checked.

Josh, one more hint: please ensure that redirectURI value that is passed from your client into Genesys Cloud is matching the redirectURI value that is defined in your ForgeRock deployment: redirectURI values must match, it's part of OIDC procedures.

Hey Angelo,

Thank you for that - will confirm with the customer.

Can I confirm if the auth script is okay?
Comparing it to the base code it doesn't include nonce, maxage, codeVerifer or ISS - not sure if this is required or if it is varies depending on the auth provider?

Hi Josh,

Yes, they are tons of extra security parameters :slight_smile:
I would suggest to not set them unless you know why.
If set or mismatch, the error is different from the one there is currently. So don't think this is an issue here.

Regarding the script, it looks ok but the redirecturi content which points to the auth server discovery document is weird.
It should be a web site app that the oauth server called upon successful authentication with various extra parameters (including the auth code).
This web site url should be properly registered within the auth server.
However this does not seem to be an issue here since Messenger did the exchange call, so received the callback (redirect uri that was set when calling the initial /authorize).
It would be better to have the same values though.

As a quick overview, login workflow is as follows:
web site will call auth server /authorize with a (registered) redirect_uri.
Upon successful authentication, auth server will do a Http redirect using the redirect_uri to send back exchange code (and possibly other extra parameters, like iss, etc).
Messenger extracts data sent back and calls Genesys auth endpoint to exchange tokens.

Searching in Forgerock faq, I could find this article which looks like close to this issue:
https://backstage.forgerock.com/knowledge/kb/article/a27814899

Hope this helps,

Regards,
V.P.

Hey VP - the customer has updated the redirectURI now - "https://dev-api.telstrasuper.com.au/api/IdentityMgmt/openidconnect/getauthorisecode"

But still getting a 401 on the code exchange
https://api.mypurecloud.com.au/api/v2/webdeployments/token/oauthcodegrantjwtexchange

I noticed someone had a similar issue on the forums with OKTA - Integrate Messenger with Okta for identity management - #3 by brad but a fix was put in (not sure if that was for the API as a whole or just for OKTA integrations)

1 Like

Hi Josh,

Checked again logs and still seeing the same error invalid_client (Invalid authentication method for accessing this endpoint.)
I still think that this article applies.

There's a mismatch in what auth server expects and what the client sends.

Note that you can manually do the exchange token using any http tools like Curl, Postman or Insomnia to find out what of request fails or succeeds.

1- Request a code exchange using /authorize endpoint
Example:
GET https://openam-telstrasuper-aus-dev.id.forgerock.io:443/am/oauth2/alpha/authorize?client_id=cliendId
&response_type=code
&response_mode=fragment
&scope=openid%20profile%20email%20offline_access
&redirect_uri=https://dev-api.telstrasuper.com.au/api/IdentityMgmt/openidconnect/getauthorisecode

2- Request code exchange:
Extract the code from the previous call and invoke url:
POST https://openam-telstrasuper-aus-dev.id.forgerock.io:443/am/oauth2/alpha/access_token

Headers:
authorization: Basic base64(<clientId>:<clientSecret>)
Content-Type: application/x-www-form-urlencoded
accept: application/json

FORM Urlencoded:
grant_type: authorization_code
redirect_uri: https://dev-api.telstrasuper.com.au/api/IdentityMgmt/openidconnect/getauthorisecode
code: <code>

If this fails, try again with clientId and secretId within the body, not as a header.

The article in the forum you are referring to was indeed a validation issue on our side but has been fixed since then.

Hope this helps.

Regards,
V.P.

Hey VP - thanks for that.

Looks like there is progress made here :slight_smile: Configuration in ForgeRock had to be set to client-secret_basic.

The next question I have is in relation to scopes. Are we expecting to see scopes included in the payload when calling /api/v2/webdeployments/token/oauthcodegrantjwtexchange?

also - would ISS need to be included in the scropt if we can see it in the JWT payload?

Hi Josh,

Nice to hear about the progress.

Regarding scopes, no they are not part of the payload.
Scopes are specified only once when calling the very first /authorize request.
Once authenticated, scopes are part of the user session and can be retrieved from the auth server.

GET https://<server>/authorize?client_id=cliendId
&response_type=code
&response_mode=fragment
&scope=openid%20profile%20email%20offline_access <==== set requires scopes
&redirect_uri=<redirect url>

Regarding iss, this is a security parameter that needs to be set only if the auth server expects it.
See RFC 9207 - OAuth 2.0 Authorization Server Issuer Identification
In short, your document discovery needs to set this option: authorization_response_iss_parameter_supported
and include the iss parameter when calling the redirect uri.

Don't set iss if this is not the case. Login will fail.
This is a general rule: Don't set a security parameter if it is not expected.

I could see some successful login requests and some errors as well because the same exchange code is being reused several times (it can be used only once).

Hope this helps.

V.P.

Yep - we were successful! Now to testing :slight_smile:

Thank you for your help :slight_smile:

Hi V.P.

Can I just confirm what the expected behaviour is in this scenario?

I've logged into the secure portal and have successfully been authenticated. The session is still active and I navigate to a different page (same domain however outside the secure portal) - is it expected that the session remains active? (taking into account the message threading timeline has been set to 5 hours)

Note this customer has two deployments - one for the public facing website and another for the secure portal.

Hi Josh,

Yes, think so.
Threading time line is different than webmessaging session time life.
This is a bit confusing I know.
Threading timeline is about "when to chunk" conversations (and then restart routing or not, display history, etc).

See Is the Web Messaging Guest session duration related to Threading Timeline? - Genesys Cloud Resource Center

Regards,
V.P.

Hey V.P.

Thanks as always for that - I see that the web messaging guest session is hard coded to 72 hours according to documentation however below is an example of that not being the case - is the documentation out of date with the new messaging disconnection options for Web Messaging?

Additionally in the developer centre this article says it stays in local storage up to a year or if the user manually deletes it

Hi Josh,

You are referring to disconnect actions that can be configured to allow a manual session disconnection (rather than time-based). So yes, 72 hours still apply but agent or end-user may close earlier the session.
See https://developer.genesys.cloud/commdigital/digital/webmessaging/websocketapi#conversation-disconnect

In Messenger configuration:

image

Regards,
V.P.

Thanks for that V.P

I've played with those settings before and we have set it to Display conversation status - but my question is more on the end-user side and how long the transcript in the widget is visible.

In the below screenshot - the end user is able to see previous conversation history from more than 72 hours of inactivity.

When is this completely cleared for the end-user (regardless of the Conversation Disconnect option) ?

Through testing it seems that the chat transcript is still visible for the end-user until they clear local storage or if "Display conversation status and disconnect session" - and they click "Start New"

image

Thanks,
Josh

Actually V.P - think i found my solution here

Hi Josh,

Glad you find out something.
I don't think indeed there's any mechanism out of the box to remove the transcript from Messenger when conversation is cleared.
Alternatively, there's an option that allows the user to manually clear the screen but that's still manual action.

image

Don't hesitate to push new ideas or vote on existing ones if you don't find what you need.
https://genesyscloud.ideas.aha.io/ideas

Regards,
V.P.

Hey VP is that manual clear enabled yet or still in beta?