feat(apps): add multi-flow OAuth lifecycle - #744
Open
Mehak Bindra (MehakBindra) wants to merge 5 commits into
Open
feat(apps): add multi-flow OAuth lifecycle#744Mehak Bindra (MehakBindra) wants to merge 5 commits into
Mehak Bindra (MehakBindra) wants to merge 5 commits into
Conversation
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
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 on the currentmicrosoft/teams.netimplementation and stacked on #729.OAuthFlowfor silent token lookup, interactive sign-in, sign-out, connection status, and completion/failure callbacksAppOptions.oauthFlowsand imperative registration withapp.addOAuthFlow(...)getOAuthFlow(...)lookup with case-insensitive connection matchingPublic API
Flows may also be registered and configured directly:
Lifecycle behavior
getToken()performs silent token lookup and reuses the existing token models.signIn()returns a cached token immediately or emits an OAuth card and records pending flow attribution.signin/tokenExchangeresolves the named flow, performs exchange, suppresses duplicates, invokes the completion callback, and emits the existingsigninevent.signin/verifyStatetries pending flows in attribution order until a connection redeems the code.signin/failureroutes the failure to the most recent pending SSO-capable flow.signOut()andgetConnectionStatus()expose the remaining per-connection operations.Compatibility
AppOptions.oauth,ctx.signin(),ctx.signout(),ctx.userToken,ctx.isSignedIn,ctx.userGraph, existing OAuth events, invoke routes, and response shapesoauth.defaultConnectionNamewith registered flows; once flows are registered, deprecated context OAuth helpers must name a connection; a configured default may be omitted or named exactlystate: falsewith registered flows is rejectedapp.options.ts, while re-exporting them fromapp.tsso existing imports continue to workOAuthFlowwhile keeping legacy-default and registered-flow modes mutually exclusiveIntentional semantics
404when no flow redeems the code, matchingteams.net, even when an earlier candidate produced a token-service5xxOAuthFlow.signIn()converts expected token-miss responses (400,404, and412) into card initiation and propagates unexpected service or transport errorsOAuthFlowwith a token-specificGraphClientinstead of deprecatedctx.userGraphDeliberate TypeScript differences
onSignInCompleteandonSignInFailurecallback typesValidation
npm test --workspace @microsoft/teams.apps -- --runInBandnpm run lint --workspace @microsoft/teams.appsnpm run build --workspace @microsoft/teams.appsnpm run lint --workspace @examples/oauthnpm run build --workspace @examples/oauthStack
mehakbindra-add-per-turn-state