我想从Angular应用程序查询Dialogflow V2,但是Authentication标头似乎不起作用。
运行此代码时,我总是收到错误代码401:
readonly baseURL: string = "https://dialogflow.googleapis.com/v2/projects/myprojectname/agent/sessions/12345:detectIntent";
readonly token = environment.dialogflow.token;
constructor(private http: HttpClient) {}
talk(query: string) {
let body = {
"queryInput": {
"text": {
"text": query,
"languageCode": "en"
}
}
}
this.http.post(this.baseURL, body, {headers: {'Authorization': `Bearer
${this.token}`}}).subscribe(
res => {
return console.log(res);
}
);
}
我做错了什么?
答案 0 :(得分:0)
现在我自己弄清楚了:我使用的是Dialogflow v1中的令牌,因此当然不起作用。