Authenticated Chat - How to pass session

I'm working through this page (https://developer.mypurecloud.com/api/webchat/authenticated-chat.html) and to the point of calling the code:

const headers = { Client-Token: 'YOUR_SESSION_IDENTIFIER_HERE' };
startChatButton.onclick = onStartChatClick;
function onStartChatClick () {
return webchat.authenticateGuest(headers)

How do you correctly apply the session to the headers? Can you provide some of the javascript code that is getting called at "authenticateGuest" so I can understand how the headers are getting applied? Is this making an ajax call and can I pass in attributes like "withCredentials", like in the example below, to be able to avoid CORS errors?

  $.ajax({
	   url: webchatAuthUrl,
	   type: "GET",
	   xhrFields: {
	      withCredentials: true
	   }
   })

See the code in the example: https://developer.mypurecloud.com/api/webchat/authenticated-chat.html#authenticated_chat_example. You would replace YOUR_SESSION_IDENTIFIER_HERE with the actual value of the session identifier.

When I do a network trace in the Chrome debugger and look at the request headers going to my authenticated chat proxy service, none of the HTTP headers that I put in the below code get applied.

const headers = { Client-Token: 'YOUR_SESSION_IDENTIFIER_HERE' };
startChatButton.onclick = onStartChatClick;
function onStartChatClick () {
return webchat.authenticateGuest(headers)

Shouldn't I be able to see a http header called "Client-Token" from the example above?

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