Skip to content

[Bug]: C# - TeamsAttachmentDownloader needs updated getAccessToken #1182

@corinagum

Description

@corinagum

Language

Javascript/Typescript

Version

latest

Description

Related to #1154.

In TeamsAttachmentDownloader, getAccessToken is hardcoded to encode the bot app id. However, this means that any app using a certificate will not work. We need to adjust the logic to support (e.g.) certificate-based authentication. Botbuilder already has methods that support fetching tokens, and that should be used instead. Furthermore, non-public Azure cloud scenarios will not work with getAccessToken because the method is using the hardcoded public url.

private async getAccessToken(): Promise<string> {
const headers = {
'Content-Type': 'application/x-www-form-urlencoded'
};
const body = `grant_type=client_credentials&client_id=${encodeURI(
this._options.botAppId
)}&client_secret=${encodeURI(
this._options.botAppPassword
)}&scope=https%3A%2F%2Fapi.botframework.com%2F.default`;
const token = await this._httpClient.post<JWTToken>(
'https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token',
body,
{ headers }
);
return token.data.access_token;
}

  • Use botbuilder's access token fetcher (lookup name of class) instead of this project's getAccessToken.
  • Support all Azure clouds (US Gov, DoD, etc.)

Reproduction Steps

N/A (internally filed)

Metadata

Metadata

Assignees

Labels

P0bugSomething isn't workingdotnetChange/fix applies to dotnet. If all three, use the 'JS & dotnet & Python' labelparityJS → dotnet and/or JS → Python

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions