Skip to content

Add mid-conversation authentication support#184

Merged
jatinjd2904 merged 11 commits intomicrosoft:mainfrom
jatinjd2904:users/jatinjd/Auth_Mid_SDK
Mar 19, 2026
Merged

Add mid-conversation authentication support#184
jatinjd2904 merged 11 commits intomicrosoft:mainfrom
jatinjd2904:users/jatinjd/Auth_Mid_SDK

Conversation

@jatinjd2904
Copy link
Copy Markdown
Contributor

@jatinjd2904 jatinjd2904 commented Feb 13, 2026

Summary

  • Added authenticateChat endpoint in SDK for mid-conversation authentication
  • Added MidConversationAuthFailure error handling with retry support
  • Added deferInitialAuth support in startChat to skip initial auth for unauthenticated mid-auth flow
  • Added telemetry event MidConversationAuth for scenario tracking
  • Added comprehensive unit tests (252 new test lines)

Test plan

  • Verify authenticateChat API call with valid token
  • Verify retry logic on authenticateChat failure
  • Verify deferInitialAuth skips auth during startChat
  • Verify existing auth flows are not affected
  • Run full test suite

🤖 Generated with Claude Code

Comment thread src/Common/OmnichannelEndpoints.ts Outdated
@bghcore
Copy link
Copy Markdown
Contributor

bghcore commented Feb 13, 2026

Overall looks good — clean implementation that follows existing patterns well. A couple things to address:

  1. Telemetry gap on validation failure (SDK.ts ~line 1548): The throw after MIDAUTHENTICATECHATSTARTED has no corresponding MIDAUTHENTICATECHATFAILED log. Every other failure path in this file logs the failure event before throwing. Please add:

    if (!chatId || !authenticatedUserToken) {
        this.logWithLogger(LogLevel.ERROR, OCSDKTelemetryEvent.MIDAUTHENTICATECHATFAILED,
            "Mid-Authenticate Chat Failed - chatId and authenticatedUserToken are required", requestId);
        throw new Error("chatId and authenticatedUserToken are required");
    }
  2. Missing semicolon on OmnichannelEndpoints.ts:39 — every other endpoint constant has one.

  3. No request body on POST (SDK.ts ~line 1569): The POST has headers but no data property. Other POST methods like sessionInit and sessionClose include data. Can you confirm the backend doesn't expect a body? If Content-Type: application/json is set (via Constants.defaultHeaders) but no body is sent, some middleware may reject it.

  4. CHANGELOG heading: Use ### Added instead of ### Added MidConversationAuthenticateChat Feature to match the existing convention.

Nice work on the retry config with authCodeNonce header overwrites, the session ID update from response headers, and the thorough test coverage (13 cases). The return after reject() in the timeout path is better than several existing methods.

@jatinjd2904 jatinjd2904 merged commit 27b39ce into microsoft:main Mar 19, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants