Skip to content

OAuthScope should be passed in to GetAppCredentialsAsync #3418

@stevengum

Description

@stevengum

Version

master/4.7.x

Describe the bug

If the OAuthScope is not passed into GetAppCredentialsAsync, the cacheKey for the AppCredentials is incorrect:

var cacheKey = $"{appId}{oAuthScope}";

When the method creates an AppCredentials, these AppCredentials will instantiate with a default OAuthScope. So the cacheKey for "some-app-id" returns an AppCredentials that should actually be stored under "some-app-idhttps://api.botframework.com/".

This is further complicated by proactive messaging to non-channel recipients which means the audience may not be a default value (see microsoft/botframework-sdk#5751).

The Claims from a skill don't indicate the final recipient of the Skill-sent message.


CreateConnectorClientAsync calls should also take a string scope parameter as this method calls GetAppCredentialsAsync().

using (var context = new TurnContext(this, activity))
{
context.TurnState.Add<IIdentity>(BotIdentityKey, claimsIdentity);
context.TurnState.Add<BotCallbackHandler>(callback);
var connectorClient = await CreateConnectorClientAsync(activity.ServiceUrl, claimsIdentity, cancellationToken).ConfigureAwait(false);

Expected behavior

Scope to be provided whenever GetAppCredentialsAsync is called, and correct cache keys.

Additional context

#3386

[bug]

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or an unintended behavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions