amazon-connect / amazon-connect-streams

Amazon Connect Streams - a browser-based contact center integration API, typically with CRM systems.
https://docs.aws.amazon.com/connect/latest/userguide/
Apache License 2.0
395 stars 315 forks source link

onAuthFail not working #900

Open zhoulhcn opened 4 months ago

zhoulhcn commented 4 months ago
function initialAmazonCCP() {
  const connect = window.connect;
  const ccpUrl = CCP_URL;
  connect.core.initCCP(ccpRef.value, {
    ccpUrl,
    loginUrl: CCP_LOGIN_SSO_URL,
    loginPopup: false
  });
}
connect.core.onAuthFail(function () {
  console.log('Core auth failed');
});
connect.core.onIframeRetriesExhausted(() => {
  console.log('Core iframe retries exhausted');
});
connect.core.onInitialized(function () {
  console.log('Core initialized');
});

I called the initialAmazonCCP method on page A, then I opened page B with the URL CCP_LOGIN_SSO_URL to login my account, At that moment, onInitialized was called on page A, that's what I expect. Then I logout my account on page B to simulate token expiration, then I refreshed page A, onAuthFail was not called,after about 1 mins onIframeRetriesExhausted be called,but onAuthFail never called.

This is my first time submitting an issue and my English is not so good. hope you can understand what I am trying to say.

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 90 days with no activity. Remove stale label or comment to keep this active.

mfulton26 commented 1 month ago

@zhoulhcn, you might be able to use connect.core.getEventBus().subscribe(connect.EventType.ACK_TIMEOUT, () => { /* handle unauthenticated state here */ });. I am experimenting with this myself and it seems to be working well except I have to sign in twice (some race condition maybe? not sure yet but I think it is unrelated to detecting an unauthenticated state).

For TypeScript type declarations, see https://github.com/amazon-connect/amazon-connect-streams/issues/934.