feat: add OAuth support for regional bots#209
Conversation
Co-authored-by: lilyydu <[email protected]>
Co-authored-by: lilyydu <[email protected]>
|
@copilot A series of updates were made here. Complete the same changes |
Co-authored-by: lilyydu <[email protected]>
Completed the refactoring from PR #394. Changes applied in commit 9982511:
The API is now simpler with Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: lilyydu <[email protected]>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull Request Overview
This PR implements configurable OAuth endpoints to support regional bot deployments in the Microsoft Teams SDK for Python, mirroring the functionality from teams.ts PRs #386 and #394. It enables bots deployed in specific regions (e.g., Europe, Asia) to use regional token endpoints instead of the global endpoint.
Key changes:
- Introduces
ApiClientSettingsdataclass for OAuth endpoint configuration with environment variable support - Updates all API clients to accept and use configurable OAuth URLs
- Adds
api_client_settingsfield toAppOptionsfor easy configuration at the application level
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/api/src/microsoft/teams/api/clients/api_client_settings.py | New dataclass and utility function for OAuth endpoint configuration |
| packages/api/src/microsoft/teams/api/clients/init.py | Exports new API client settings classes |
| packages/api/src/microsoft/teams/api/clients/api_client.py | Accepts and propagates API client settings to all sub-clients |
| packages/api/src/microsoft/teams/api/clients/bot/client.py | Passes settings to token and sign-in clients |
| packages/api/src/microsoft/teams/api/clients/bot/sign_in_client.py | Uses configurable OAuth URL with endpoint constants |
| packages/api/src/microsoft/teams/api/clients/bot/token_client.py | Accepts and stores API client settings |
| packages/api/src/microsoft/teams/api/clients/user/client.py | Passes settings to token client |
| packages/api/src/microsoft/teams/api/clients/user/token_client.py | Uses configurable OAuth URL with endpoint constants |
| packages/api/src/microsoft/teams/api/clients/conversation/client.py | Propagates settings to activity and member clients |
| packages/api/src/microsoft/teams/api/clients/conversation/activity.py | Accepts API client settings parameter |
| packages/api/src/microsoft/teams/api/clients/conversation/member.py | Accepts API client settings parameter |
| packages/api/src/microsoft/teams/api/clients/team/client.py | Accepts and stores API client settings |
| packages/api/src/microsoft/teams/api/clients/meeting/client.py | Accepts and stores API client settings |
| packages/apps/src/microsoft/teams/apps/options.py | Adds api_client_settings field to app options |
| packages/apps/src/microsoft/teams/apps/app.py | Passes settings to API client and activity processor |
| packages/apps/src/microsoft/teams/apps/app_process.py | Accepts and uses settings when building API clients |
| packages/apps/tests/test_app_process.py | Updates test to pass None for new parameter |
| packages/api/tests/unit/test_user_client.py | Adds 7 new tests for regional endpoint functionality |
| packages/api/tests/unit/test_bot_client.py | Adds 2 new tests for bot regional endpoints |
| tests/graph/src/main.py | Adds example usage in comments |
| tests/graph/README.md | Adds regional bot configuration documentation |
| packages/mcpplugin/src/microsoft/teams/mcpplugin/server_plugin.py | Formatting change to decorator |
Co-authored-by: lilyydu <[email protected]>
Co-authored-by: lilyydu <[email protected]>
## Release 2.0.0a6 ### Changes - Make images required for Thumbnail (#216) - Revert "Add comment" - Add comment - Move tests to examples (#199) - Bump glob from 11.0.3 to 11.1.0 in /tests/tab/Web (#215) - Remove Agents class (#213) - Add signin/failure invoke activity support (#206) - Update config.yml (#214) - Adds a github template when New issues are created (#212) - feat: add OAuth support for regional bots (#209) - [feat] Add BotBuilder Plugin package, sample and tests (#190) Co-authored-by: lilydu <[email protected]>
Plan: Add OAuth Support for Regional Bots ✅ COMPLETE
This PR implements OAuth support for regional bots in Python, mirroring the TypeScript implementation.
Summary of Changes
API Layer (
packages/api)ApiClientSettings: New dataclass for OAuth endpoint configurationhttps://token.botframework.comhttps://europe.token.botframework.com)OAUTH_URLenvironment variableBaseClient: Now handlesapi_client_settingsfor all subclassesapi_client_settingsparameter to constructormerge_api_client_settingsinternallyApps Layer (
packages/apps)AppOptions.default_connection_name: OAuth connection name (defaults to "graph")AppOptions.api_client_settings: Top-level field for API client configurationOAuthSettings: Simplified API by keeping all config inAppOptionsoptions.oauth.default_connection_nametooptions.default_connection_nameExample Usage
Testing
Latest Changes
api_client_settingshandling toBaseClientfor inheritancemerge_api_client_settingscalls from subclassesmerge_api_client_settingsimportsOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.