Skip to content

Add conditions to choose ConnectorClient scope#728

Draft
sw-joelmut wants to merge 4 commits intomainfrom
southworks/add/connector-scope-default-scope
Draft

Add conditions to choose ConnectorClient scope#728
sw-joelmut wants to merge 4 commits intomainfrom
southworks/add/connector-scope-default-scope

Conversation

@sw-joelmut
Copy link
Copy Markdown
Collaborator

Fixes #723

Description

This PR adds a condition to only use the azp and appid JWT identity values when the Activity.Recipient.Role is Skill, otherwise will resolve api.botframework.com as scope.

Testing

The following image shows the Agent to Agent operations using MSTeams and WebChat
image

@sw-joelmut sw-joelmut requested a review from a team as a code owner February 25, 2026 16:58
@github-actions github-actions bot added ML: Core Tags changes to core libraries ML: Tests Tags changes to tests labels Feb 25, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a 401 authentication error that occurs when using TeamsInfo.getMember on incoming webhooks by implementing role-based scope resolution for ConnectorClient authentication. The solution differentiates between agent-to-agent (skill) communication and regular channel communication.

Changes:

  • Added ResolveConnectorClientScopes method to determine appropriate OAuth scopes based on the activity's recipient role
  • Modified ProcessActivityAsync to use the new scope resolution logic instead of always using AgentClaims.GetTokenScopes
  • Added comprehensive test coverage for all scope resolution scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/libraries/Builder/Microsoft.Agents.Builder/ChannelServiceAdapterBase.cs Implements conditional scope resolution logic that uses BotFramework scope by default and agent appId scope only for Skill role
src/tests/Microsoft.Agents.Builder.Tests/ChannelServiceAdapterBaseTests.cs Adds three test cases covering non-skill role, skill role with agent ID, and skill role without agent ID scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sw-joelmut sw-joelmut marked this pull request as draft March 5, 2026 14:13
@tracyboehrer
Copy link
Copy Markdown
Member

@sw-joelmut We can hold on this for now. We will need to revisit concerning the teams client, but since that is getting changed soon, we can wait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ML: Core Tags changes to core libraries ML: Tests Tags changes to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TeamsInfo.getMember returns 401 on incoming webhook

4 participants