Repository navigation
Make App.token_provider tenant defaults scope-aware - #624
Open
Shivam Sharma (ShivamSharma43) wants to merge 1 commit into
Open
Shivam Sharma (ShivamSharma43) wants to merge 1 commit into
Shivam Sharma (ShivamSharma43) wants to merge 1 commit into
Conversation
TokenManager.get_app_token now picks the fallback tenant from the requested scope: the cloud login tenant for the Bot Framework scope, "common" for Graph, and none for other scopes, which then require an explicit or configured tenant. App._get_graph_token drops its own fallback so App.token_provider and the internal Graph path resolve tenants in one place. Fixes microsoft#534 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Fixes #534
TokenManager.get_app_token()fell back to the cloud's Bot Framework login tenant for every scope. On a multi-tenant app,app.token_provider.get_app_token(app.cloud.graph_scope)therefore built its MSAL client againstbotframework.com, whileApp._get_graph_token()usedcommon.Tenant resolution now lives only in
TokenManagerand depends on the scope:cloud.login_tenant"common"ValueErrorApp._get_graph_token()no longer applies its own fallback, so the public provider and the internal Graph path can't disagree. The internaldefault_tenant_idkeyword onTokenManager.get_app_tokenis removed, because the default now comes from the scope.The tests run the real
TokenManagerand assert the MSAL authority for each case: the bot and Graph defaults for a multi-tenant app, an explicit or configured tenant for other scopes, and the error when no tenant is available. The app-level test checks that_get_graph_token()andtoken_provider.get_app_token(graph_scope)resolve the same tenant.ruff check,ruff format --checkandpyrightare clean, andpytest packages/appspasses (1086 tests).Note: for other scopes I chose to require a tenant instead of defining a fallback. That also applies to managed identity credentials, which don't use the tenant. I'm happy to relax that if you'd prefer.