Skip to main content
Post a question

Notifications

Community site session details

Community site session details

Session Id : jlyA/XyAnTrYl25OOJxZJu
Service | Customer Service, Contact Center, Fie...
Suggested answer

Live Chat Widget Fails to Restart After Minimizing (Token Issue)

Like (1) ShareShare
ReportReport
Posted on 24 Mar 2025 07:10:45 by 5

Problem:

I'm integrating the Microsoft Omnichannel Live Chat Widget in a React Native WebView. The chat starts successfully with an authentication token, but after minimizing and reloading, the chat fails to restart and throws authentication errors.

Errors Encountered:

  1. "Failed to find auth function on the web page"
  2. "Auth token provider method execution failed"
  3. "Auth token provider didn't provide any token"
  4. "Chat found in cache but invalid as the conversation status is inactive."
  5. "Authentication failed: Unexpected error while getting token"

Observations:

  • With an internal token, the chat restarts without issues.
  • With an external token, the chat fails after minimizing/reloading.
  • Starting a new chat with the same token works fine, but reloading does not.

Possible Causes:

  1. Token Expiry / Invalid Scopes â€“ External token may not support session persistence.
  2. Chat Widget Configuration Differences â€“ Internal vs. external settings might differ.
  3. Auth Token Not Refreshing on Reload â€“ LiveChat may require a fresh token after minimizing.

What I’ve Tried:

  • Checking token expiration (exp) and scopes.
  • Ensuring setAuthTokenProvider() is called properly.
  • Testing manual token refresh before restarting the chat.

Question:

How can I ensure the chat restarts properly after minimizing/reloading? Do I need to refresh the token dynamically, or is there a chat widget setting that handles this?

Screenshot 2025-0...

Your file is currently under scan for potential threats. Please wait while we review it for any viruses or malicious content.

  • AB-24030705-0 Profile Picture
    5 on 26 Mar 2025 at 10:18:03
    Live Chat Widget Fails to Restart After Minimizing (Token Issue)
    After throw Testing this I find out the actual issue: 

    Description:

    We are using the D365 Omni-Channel Customer Support Chat Web Widget for our client, and during testing, we encountered an issue with the authenticated chat widget.

    Issue Details:

    • When a user starts an authenticated chat session, the conversation begins normally.

    • However, if the page is refreshed, the chat session is lost.

    • When reopening the chat, a new session starts instead of resuming the previous session.

    Expected Behavior:

    • The chat session should persist even after a page reload, allowing users to continue their previous conversation rather than starting a new session.

  • Suggested answer
    Holly Huffman Profile Picture
    4,023 on 24 Mar 2025 at 12:10:32
    Live Chat Widget Fails to Restart After Minimizing (Token Issue)
    Hi there! Good morning, evening, or afternoon - depending on where you are :) Hope you are well today! 
     
    It sounds like you're facing a token persistence issue with the Microsoft Omnichannel Live Chat Widget in your React Native WebView implementation. Here are some insights and design recommendations to address this:
    • Root Cause Analysis
    • The errors and observations suggest that external tokens fail due to one or more of these potential causes:
      • Token Expiry: External tokens may have shorter lifetimes or lack refresh capabilities.
      • Session Persistence: Reloading the WebView might clear session data, requiring a fresh token.
      • WebView-Specific Behavior: WebView may not fully reload or handle cookies/session storage in the same way a standard browser would.
      • Authentication Scope: External token scopes might lack permissions for maintaining session validity on reload.
    • Solution Design
    • To ensure proper chat restart after minimizing or reloading, focus on dynamically refreshing tokens and managing session states effectively. Here’s how:
    • Dynamic Token Refresh
      • Implement token refresh logic in your app using the external token provider.
      • When reloading the WebView, check token expiration (exp field) and call the token provider method to obtain a fresh token dynamically.
      • Example:
        javascript
        const refreshToken = async () => {
          const newToken = await tokenProvider.refreshToken();
          liveChatWidget.setAuthTokenProvider(() => Promise.resolve(newToken));
        };
    • Handling Token in WebView
      • Ensure that tokens are stored securely in a location that survives reloads (e.g., React state, Secure Storage, or AsyncStorage).
      • Upon minimizing or reloading, retrieve the stored token and reinitialize the chat widget:
        javascript
        const token = await AsyncStorage.getItem('authToken');
        liveChatWidget.setAuthTokenProvider(() => Promise.resolve(token));
    • Session Cache Management
      • Check the widget’s internal session cache:
        • Use the LiveChat SDK's methods to validate whether the cached session is still active.
        • If invalid, forcefully clear the cache and restart the chat with a fresh token.
    • External Token Scopes
      • Verify that the external token includes the necessary scopes for session persistence. Scopes may include:
        • Chat.ReadWrite
        • Conversation.Start
      • Contact your external token provider to ensure scopes match the requirements for the chat widget.
    • Implement WebView Lifecycle Management
      • Detect WebView reload or minimize events using lifecycle hooks (onPause, onResume).
      • On reload:
        • Trigger token refresh and reinitialize the chat widget to maintain session continuity.
    • Configuration Recommendations
      • Internal vs. External Tokens: Compare the configuration for both token providers. Confirm whether internal tokens offer capabilities (like refresh or additional scopes) that are missing in external tokens.
      • Chat Widget Settings: Ensure the widget’s setAuthTokenProvider() is properly invoked during initialization and re-initialization after reload.
    • Fallback Option
      • If dynamic token refresh is not possible, consider displaying a custom error message to users when the token fails. Provide an option to start a new chat session manually.
    • Next Steps
      • Test these solutions thoroughly in your dev environment, ensuring that tokens refresh seamlessly after minimizing or reloading.
      • If the issue persists, contact Microsoft Support with detailed logs, including the errors mentioned.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,325 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,223 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Loading complete