Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/emulator/core/src/facility/botEndpoint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ describe('BotEndpoint', () => {
try {
const response = await (endpoint as any).getAccessToken();
} catch (e) {
expect(e).toEqual(new Error('Refresh access token failed with status code: 404'));
expect(e).toEqual({ body: undefined, message: 'Refresh access token failed with status code: 404', status: 404 });
}
});
});
24 changes: 16 additions & 8 deletions packages/emulator/core/src/facility/botEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,17 @@ export default class BotEndpoint {

public async fetchWithAuth(url: string, fetchOptions: any = {}, forceRefresh: boolean = false) {
if (this.msaAppId) {
fetchOptions.headers = {
...fetchOptions.headers,
Authorization: `Bearer ${await this.getAccessToken(forceRefresh)}`,
};
try {
fetchOptions.headers = {
...fetchOptions.headers,
Authorization: `Bearer ${await this.getAccessToken(forceRefresh)}`,
};
} catch (e) {
return {
status: e.status,
text: "The bot's Microsoft App Id or Microsoft App Password is incorrect.",
};
}
}

const response = await this._options.fetch(url, fetchOptions);
Expand Down Expand Up @@ -144,10 +151,11 @@ export default class BotEndpoint {

return this.accessToken;
} else {
// this.facilities.logger.logError(this.conversationId, 'Error: The bot\'s MSA appId or password is incorrect.');
// this.facilities.logger.logError(this.conversationId, makeBotSettingsLink('Edit your bot\'s MSA info'));

throw new Error('Refresh access token failed with status code: ' + resp.status);
throw {
message: 'Refresh access token failed with status code: ' + resp.status,
status: resp.status,
body: resp.body,
};
}
}
}
2 changes: 1 addition & 1 deletion packages/emulator/core/src/facility/conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export default class Conversation extends EventEmitter {
'/v3/directline/conversations'
),
networkResponseItem(
{ id: result.activityId },
{ ...result.response, id: result.activityId },
result.response.headers,
result.statusCode,
result.status,
Expand Down