feat(apps): add multi-flow OAuth lifecycle - #744
Open
Mehak Bindra (MehakBindra) wants to merge 15 commits into
Open
feat(apps): add multi-flow OAuth lifecycle#744Mehak Bindra (MehakBindra) wants to merge 15 commits into
Mehak Bindra (MehakBindra) wants to merge 15 commits into
Conversation
Mehak Bindra (MehakBindra)
force-pushed
the
mehakbindra-oauth-lifecycle
branch
from
August 24, 2026 21:59
dfcdccf to
3513be0
Compare
Mehak Bindra (MehakBindra)
force-pushed
the
mehakbindra-oauth-lifecycle
branch
5 times, most recently
from
August 25, 2026 21:05
c5fa1a2 to
d372ac6
Compare
Mehak Bindra (MehakBindra)
force-pushed
the
mehakbindra-oauth-lifecycle
branch
3 times, most recently
from
August 26, 2026 00:39
3f7dc77 to
18b6163
Compare
Add per-connection OAuth flows, lifecycle callbacks, multi-flow invoke routing, pending attribution, exchange deduplication, telemetry, compatibility fallbacks, and the OAuth example. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d88953d-cdee-4a28-ac2d-36a5fee72da5
Validate deprecated context sign-in connections before initiation, record pending attribution for the selected flow, expose the completed connection on signin events, and keep internal OAuth helpers out of the package barrel. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d88953d-cdee-4a28-ac2d-36a5fee72da5
Treat the implicit default as a normal flow, standardize completion error semantics, and preserve plugin-provided context in OAuth lifecycle callback types. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d88953d-cdee-4a28-ac2d-36a5fee72da5
Automatically enable turn state for explicit OAuth flows, reject state: false, store pending attribution and bounded exchange deduplication in state, and require exact token-exchange routing. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d88953d-cdee-4a28-ac2d-36a5fee72da5
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d88953d-cdee-4a28-ac2d-36a5fee72da5
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d88953d-cdee-4a28-ac2d-36a5fee72da5
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d88953d-cdee-4a28-ac2d-36a5fee72da5
Mehak Bindra (MehakBindra)
force-pushed
the
mehakbindra-oauth-lifecycle
branch
from
August 26, 2026 23:27
18b6163 to
f9af48f
Compare
Copilot started reviewing on behalf of
Mehak Bindra (MehakBindra)
August 26, 2026 23:27
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a first-class multi-connection OAuth lifecycle to @microsoft/teams.apps, introducing a per-connection OAuthFlow API (token lookup, interactive sign-in/out, status, and callbacks) while preserving legacy ctx.signin()/ctx.signout() compatibility paths with stricter error handling and optional state-backed deduplication/attribution.
Changes:
- Introduces
OAuthFlow,OAuthFlowRegistry, and default invoke handlers to routesignin/tokenExchange,signin/verifyState, andsignin/failureacross multiple registered connections with telemetry and deduplication. - Integrates OAuth-flow-driven pending attribution + exchange deduplication with per-turn state (auto-enabled when flows are registered unless
state: false). - Replaces the prior Graph-only example with a multi-provider OAuth example (Graph + GitHub) and updates exports/public options layout.
Reviewed changes
Copilot reviewed 26 out of 33 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates examples list to point to the new OAuth sample. |
| packages/apps/src/state/loader.ts | Adds an OAuth-specific state loader helper and centralizes LocalStorage warnings. |
| packages/apps/src/oauth/telemetry.ts | New OAuth operation tracing + metrics/attributes recording helpers. |
| packages/apps/src/oauth/registry.ts | New registry for legacy-default vs multi-flow mode + installs invoke routes. |
| packages/apps/src/oauth/index.ts | Implements OAuthFlow lifecycle API and shared sign-in helper; keeps legacy OAuth settings. |
| packages/apps/src/oauth/handlers.ts | New multi-flow invoke handlers for token exchange, verify-state, and signin failure routing. |
| packages/apps/src/oauth/handlers.spec.ts | Updates/extends handler tests for multi-flow routing, dedupe, attribution, and telemetry. |
| packages/apps/src/oauth/flow.spec.ts | Adds focused tests for OAuthFlow lifecycle behavior and telemetry. |
| packages/apps/src/oauth.ts | Removes legacy standalone OAuth settings module (moved under oauth/). |
| packages/apps/src/index.ts | Re-exports new OAuthFlow surfaces and types from the package entrypoint. |
| packages/apps/src/diagnostics/constants.ts | Consolidates OAuth span name and expands OAuth operation/result constants. |
| packages/apps/src/contexts/activity.ts | Refactors deprecated signin() helper to use shared OAuth sign-in logic + flow validation hooks. |
| packages/apps/src/contexts/activity.test.ts | Updates tests for new signin error semantics and pending attribution hooks. |
| packages/apps/src/app.ts | Wires OAuthFlowRegistry, declarative oauthFlows, and OAuth-driven state enabling into App. |
| packages/apps/src/app.spec.ts | Adds App-level tests for flow registration, case-insensitive lookup, and state behavior. |
| packages/apps/src/app.process.ts | Switches to getStateLoader() so state can become available after OAuth flow registration. |
| packages/apps/src/app.process.spec.ts | Adds coverage for state enablement + legacy helper validation under registered flows. |
| packages/apps/src/app.plugin.spec.ts | Verifies plugin-provided context fields flow through OAuth lifecycle callbacks. |
| packages/apps/src/app.options.ts | Extracts AppOptions (and related types) into a dedicated module and adds oauthFlows. |
| packages/apps/src/app.oauth.ts | Removes legacy single-flow OAuth handlers implementation (replaced by new flow system). |
| package-lock.json | Updates workspace deps and adds new example package; contains lockfile churn/stale workspace entry. |
| examples/oauth/turbo.json | Adds Turbo build task config for the new OAuth example. |
| examples/oauth/tsconfig.json | Adds TS build config for the OAuth example. |
| examples/oauth/src/index.ts | New OAuth sample demonstrating Graph + GitHub flows and callbacks. |
| examples/oauth/README.md | Updates sample docs for multi-provider OAuth setup and commands. |
| examples/oauth/package.json | Renames example package to @examples/oauth and adds Graph client dependency. |
| examples/oauth/eslint.config.js | Adds ESLint config wiring for the new example. |
| examples/oauth/CHANGELOG.md | Renames changelog header to match new example package name. |
| examples/oauth/appPackage/outline.png | Adds new example app assets (LFS pointers). |
| examples/oauth/appPackage/manifest.json | Updates manifest name/description to match multi-provider OAuth example. |
| examples/oauth/appPackage/color.png | Adds new example app assets (LFS pointers). |
| examples/oauth/.gitignore | Adds example-local ignores for Teams tooling and build artifacts. |
| examples/graph/src/index.ts | Removes the old Graph-only example entrypoint. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d88953d-cdee-4a28-ac2d-36a5fee72da5
Mehak Bindra (MehakBindra)
force-pushed
the
mehakbindra-oauth-lifecycle
branch
from
August 26, 2026 23:48
f9af48f to
a36b564
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d88953d-cdee-4a28-ac2d-36a5fee72da5
Mehak Bindra (MehakBindra)
requested review from
Corina (corinagum) and
Lily Du (lilyydu)
August 27, 2026 00:12
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d88953d-cdee-4a28-ac2d-36a5fee72da5
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d88953d-cdee-4a28-ac2d-36a5fee72da5
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d88953d-cdee-4a28-ac2d-36a5fee72da5
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d88953d-cdee-4a28-ac2d-36a5fee72da5
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d88953d-cdee-4a28-ac2d-36a5fee72da5
Retain the existing Graph example and direct multi-connection users to the OAuthFlow sample. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d88953d-cdee-4a28-ac2d-36a5fee72da5
Corina (corinagum)
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a first-class, per-connection OAuth lifecycle to
@microsoft/teams.apps, modeled onmicrosoft/teams.netand using the turn-state support from #729.OAuthFlowfor silent token lookup, interactive sign-in, sign-out, and completion/failure callbacksAppOptions.oauthFlows,app.addOAuthFlow(...), andapp.getOAuthFlow(...)ctx.getConnectionStatus(), including direct token checks that correct stale silent-SSO status resultsPublic API
Compatibility and behavior
state: falsekeeps bounded process-local tracking400,404,412) trigger interactive fallback; unexpected service or transport failures propagateBreaking changes
ctx.signin()previously treated every token lookup failure as a missing token and sent an OAuth card. It now sends a card only for expected token-miss responses (400,404,412). Unexpected service and transport failures propagate and may produce a500for the turn instead of silently switching to interactive sign-in.microsoft.teams.oauth, withoauth.operationdistinguishing token exchange, verification, and failure. Existingoauth.resultvalues also move to lifecycle-specific values. Dashboards and alerts using the previous span names or result values must migrate; this must be called out in the release changelog. The non-HTTP error value remainsexception.