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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Answered

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

(2) ShareShare
ReportReport
Posted on by 9

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.

I have the same question (0)
  • Verified answer
    Holly Huffman Profile Picture
    6,530 Super User 2025 Season 2 on at
    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.
  • AmirZubair Profile Picture
    9 on at
    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 55 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 25 Most Valuable Professional

#3
Soundari Profile Picture

Soundari 15

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans