Skip to main content

Notifications

Announcements

No record found.

Service | Customer Service, Contact Center, Fie...
Unanswered

Omnichannel Chat Authentication with JWT

(1) ShareShare
ReportReport
Posted on by 2
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?

  • 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. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans