Skip to main content

Notifications

Customer Service forum
Unanswered

Omnichannel Chat Authentication with JWT

Posted on by
Hello,
 I have tried to implement Authentication settings in Omnichannel chat on a custom Portal. I have followed the steps accordingly to the documentation: https://learn.microsoft.com/en-us/dynamics365/customer-service/administer/create-chat-auth-settings?tabs=customerserviceadmincenter#setup-for-custom-portals. I have exposed 2 endpoints: one is the public.key endpoint and the second exposes the JWT encoded token  and the other exposes a JWT token encoded with RS256 algorithm and private key. The token validated the public.key as a signature.  
On widget load, the js library fires and retrieves the token (I can see it in debugger mode) but after that it does not authenticate the user. I get a 401 response(Unauthorized). I have checked and both enpoints return values as specified, the token validaed encoding, the header is well formatted, lwicontext is added in the payload to the mandatory claims.
the js is like this: 
auth.getAuthenticationToken = function (callback) {
            var xhttp = new XMLHttpRequest();
            xhttp.onreadystatechange = function () {
                if (this.readyState == 4 && this.status == 200) {
                    callback(xhttp.responseText);
                }
            };
            xhttp.onerror = function (error) {
                callback(null);
            };
            //Call to your token generating service
            xhttp.open(/GET/, https://mycustomportal.azurewebsites.net/api/token/get/, true);
            xhttp.send();
What I am missing?

Categories:
  • Suggested answer
    MO-10051346-0 Profile Picture
    MO-10051346-0 2 on at
    Omnichannel Chat Authentication with JWT
    No idea if this is your problem, and I am new to this as well, but I had the exact same issue. We tried for two days to resolve with no luck.  Same 401 error. 
     
    Finally, someone on the team noticed that the token was created in GMT timezone, and we were in Central US timezone.  The token was created, but instantly expired because the time zones were off.   Fixing this, fixed the 401 error.
     
    Worth a check.  Hope it helps. 

Helpful resources

Quick Links

Take the Community feedback survey!

Answer this brief 15-question survey about your Community experience…

Demystifying Copilot: Service Edition with Sundar Raghavan

Sundar answers more questions about Copilot for Service...

Dynamics 365 Business Central vs Finance and SCM

Take a look at the key differences between Business Central and…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,377 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 223,308 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,140

Featured topics

Product updates

Dynamics 365 release plans