【发布时间】:2019-01-22 14:04:19
【问题描述】:
我正在使用 DirectLine v3 在我的网站中实现一个使用 Azure Bot Framework 的机器人。我正在尝试按照此处的说明开始对话:https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-start-conversation?view=azure-bot-service-4.0
当我发送 HTTP Post 时,我收到状态为 403 Forbidden 的响应错误。有人可以建议我为什么会收到 403 禁止响应吗?我在 Angular 应用程序中使用它。
我的 HTTP 帖子的代码:
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http'
import 'rxjs/Rx';
@Injectable()
export class BotFramework {
secret = 'SECRET';
constructor(private httpClient: HttpClient) {}
authenticate() {
const headerAuth = new Headers({
'Authorization': 'Bearer ' + this.secret
});
return this.httpClient.post('https://directline.botframework.com/v3/directline/conversations',{
observe: 'response',
response: 'json',
})
.map(
(response) => {
const data = response;
console.log('Returned response: ' + response);
return data;
}
)
}
}
我在这里的 Angular 组件中使用它:
//Azure Bot Framework code goes here
setTimeout(() => {
this.botFramework.authenticate()
.subscribe(
(authentification: any) => {
console.log(authentification);
(error) => console.log('Authentification error: ' + error);
}
)
}, 1000)
所以消息说缺少秘密或令牌(我提供了秘密)。我想我在设置 HTTP Post 时一定做错了,因为 Azure 无法找到我的秘密。如果我正确地假设这是错误,我如何正确发送 HTTP Post 以便 Azure 找到密钥?
【问题讨论】: