[apps/api] feat: allow oauth for regional bots#386
Merged
Conversation
|
Loving it 😍 Thanks a lot @lilyydu for your work on this. I have several comments after going through the changes. Have you considered using OAuthUrl as the setting's name instead of tokenUrl? I understand the choice for tokenUrl as it is the URL to get the token but the bot service doc talks about OAuth URL in OAuth URL support in Azure AI Bot Service for example so it might be good to be aligned. Regarding the instructions for setting up:
Regarding the CLI templates:
|
corinagum
reviewed
Nov 7, 2025
… instructions to test sample README
heyitsaamir
reviewed
Nov 7, 2025
heyitsaamir
reviewed
Nov 7, 2025
lilyydu
commented
Nov 10, 2025
heyitsaamir
approved these changes
Nov 11, 2025
Jesperholmbergmsft
approved these changes
Nov 11, 2025
lilyydu
added a commit
to microsoft/teams.py
that referenced
this pull request
Nov 14, 2025
## 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 configuration - Defaults to `https://token.botframework.com` - Supports regional endpoints (e.g., `https://europe.token.botframework.com`) - Reads from `OAUTH_URL` environment variable - **`BaseClient`**: Now handles `api_client_settings` for all subclasses - Added `api_client_settings` parameter to constructor - Calls `merge_api_client_settings` internally - All client subclasses inherit this functionality - **Client updates**: All API clients now inherit settings handling from BaseClient - **Endpoint constants**: Added for maintainability - **Docstrings**: Updated to "Optional API client settings." for consistency #### Apps Layer (`packages/apps`) - **`AppOptions.default_connection_name`**: OAuth connection name (defaults to "graph") - **`AppOptions.api_client_settings`**: Top-level field for API client configuration - **Removed `OAuthSettings`**: Simplified API by keeping all config in `AppOptions` - **Updated references**: Changed from `options.oauth.default_connection_name` to `options.default_connection_name` ### Example Usage ```python from microsoft.teams.api import ApiClientSettings from microsoft.teams.apps import App # Configure for Europe region app = App( default_connection_name='graph', api_client_settings=ApiClientSettings( oauth_url="https://europe.token.botframework.com" ) ) ``` ### Testing - All 109 API unit tests passing - Linting passed (ruff) - Type checking passed (pyright) ### Latest Changes - ✅ Moved `api_client_settings` handling to `BaseClient` for inheritance - ✅ All client subclasses now pass settings to BaseClient constructor - ✅ Removed duplicate `merge_api_client_settings` calls from subclasses - ✅ Simplified imports by removing unused `merge_api_client_settings` imports <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > in the Python repository, apply similar changes to this Typescript PR <a href="microsoft/teams.ts#386" rel="noreferrer noopener" title="microsoft/teams.ts#386" target="_blank">[apps/api] feat: allow oauth for regional bots by lilyydu · Pull Request #386 · microsoft/teams.ts</a> <attachment id="app-preview-card-ps8c1976db18534edbae026f7a1afc8b5e"></attachment> </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: lilyydu <[email protected]> Co-authored-by: lilydu <[email protected]> Co-authored-by: Lily Du <[email protected]>
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.
resolves: #367
ClientSettingsthats passed into our clients from the app layertokenUrlspecifies the regional token endpoint to use (e.g., europe.token.botframework)I didn't reuse
OauthSettingsbecausea) its associated w/ the Apps ecosystem vs
ClientSettingsis concerned w the API layerb) eventually may diverge with additional params
b) would cause circular dependencies
INSTRUCTIONS FOR SETTING UP
(documenting here for now, should add to docs, partial courtesy to @Benjiiim):
resources: