web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested Answer

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
    2 on at
    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. 
  • shriramayushnvs Profile Picture
    6 on at
    Hi, Did you find the exact reason why this was happening?

    I am using the chat widget on power pages portal with MS Entra ID sign in.
     
    Any help would be appreciated.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Daniyal Khaleel Profile Picture

Daniyal Khaleel 58 Most Valuable Professional

#2
Travis South Profile Picture

Travis South 37

#3
11manish Profile Picture

11manish 22 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans