Skip to content

DRAFT - feat: add multi-connection OAuth registry and flow APIs - #561

Draft
Lily Du (lilyydu) wants to merge 1 commit into
lilyydu/02-state-apifrom
lilyydu/03-oauth-registry
Draft

DRAFT - feat: add multi-connection OAuth registry and flow APIs#561
Lily Du (lilyydu) wants to merge 1 commit into
lilyydu/02-state-apifrom
lilyydu/03-oauth-registry

Conversation

@lilyydu

@lilyydu Lily Du (lilyydu) commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds the public OAuth flow/registry surface that lets apps register and
use multiple named OAuth connections instead of relying only on the app-level
default connection.

The shape mirrors the C# SDK’s OAuthFlow / AddOAuthFlow(...) model while
remaining additive for existing teams.py apps.

What changed

OAuth flow registry

  • Added OAuthFlow, representing one named OAuth connection.
  • Added OAuthFlowRegistry, a case-insensitive, insertion-ordered registry.
  • Added App.add_oauth_flow(...) to register a connection and return its flow.
  • Added App.get_oauth_flow(...) to retrieve a registered flow by connection name.
  • Duplicate connection names raise ValueError case-insensitively.

Flow operations
Each OAuthFlow can now operate against its own connection:

github = app.add_oauth_flow("github")

await github.sign_in(ctx)
await github.sign_out(ctx)
token = await github.get_token(ctx)
signed_in = await github.is_signed_in(ctx)

OAuthFlow.sign_in(...) always forces the flow’s connection name, so callers cannot accidentally pass options for one connection through another flow.

ActivityContext OAuth helpers

  • ctx.sign_out(connection_name=...) can now sign out a specific connection.
  • ctx.get_user_token(connection_name=...) reads a token for a specific connection.
  • Returns None for Token Service 404 / not signed in.
  • Re-raises non-404 failures so service outages are not masked as logged-out users.
  • ctx.get_token_status() retrieves status for all registered bot OAuth connections.

Events

  • Added SignInFailureEvent.
  • Sign-in failure now emits both:
    -> the existing ErrorEvent for backward compatibility;
    -> the new sign_in_failure event with connection name/code/message details.

Public exports

  • Re-exported OAuthFlow and OAuthFlowRegistry from microsoft_teams.apps.

@lilyydu
Lily Du (lilyydu) force-pushed the lilyydu/03-oauth-registry branch from 7f73326 to 3cb3dac Compare August 13, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant