如何使用 Dialogflow V2 查询修复身份验证错误
How to fix Authentication error with Dialogflow V2 query
我想从 Angular 应用程序查询 Dialogflow V2,但身份验证 header 似乎不起作用。
当我 运行 此代码时,我总是收到错误代码 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);
}
);
}
我做错了什么?
我现在自己弄明白了:我使用的是 Dialogflow v1 中的令牌,所以它当然不起作用。
我想从 Angular 应用程序查询 Dialogflow V2,但身份验证 header 似乎不起作用。
当我 运行 此代码时,我总是收到错误代码 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);
}
);
}
我做错了什么?
我现在自己弄明白了:我使用的是 Dialogflow v1 中的令牌,所以它当然不起作用。