我一直在尝试将Azure Direct Line API v3.0用于机器人。然而,似乎我不再启用对话,因为我在APi呼叫上收到403消息。这是我的电话:
CREATE TYPE days_of_the_week as enum (
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'
);
CREATE TABLE company (
id SERIAL PRIMARY KEY NOT NULL,
company_name CHARACTER VARYING(1024) NOT NULL
);
CREATE TABLE company_active (
id_company integer NOT NULL REFERENCES company(id) ON DELETE CASCADE,
days days_of_the_week NOT NULL
);
ALTER TABLE company_active
ADD CONSTRAINT company_active_unique UNIQUE (id_company, days);
INSERT INTO company (company_name) VALUES ('test');
INSERT INTO company_active (id_company, days)
SELECT id, 'Monday'::days_of_the_week
FROM company;
INSERT INTO company_active (id_company, days)
SELECT id, 'Tuesday'::days_of_the_week
FROM company;
请注意,过去这几天都会工作。我有通过此API创建的活动的几个活动记录。
但是现在我甚至在获取令牌时不断收到此错误消息:
$.ajax({
url: "https://directline.botframework.com/v3/directline/tokens/generate",
method: "POST",
crossDomain: true,
cache: false,
beforeSend: function (xhr) {
/* Authorization header */
xhr.setRequestHeader ("Authorization", "Basic " + btoa("Bearer:GI3UQr2GYoA.cwA.wHo.h1AyNQKXSESWZGFrf-yf_Cm3XwDRy38Yn-xzgUton-E"));
},
success: function (data) {
},
error: function (jqXHR, textStatus, errorThrown) {
}
});
我正在使用免费订阅计划,我还剩7天。此外,我已检查订阅状态,其活动状态。我也有超过140美元的信贷。
请让我知道我做错了什么,为什么这会突然停止工作?
提前致谢。
答案 0 :(得分:6)
阅读MS提供的有关身份验证的文档:https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication?view=azure-bot-service-3.0
它说:
Authorization: Bearer SECRET_OR_TOKEN
所以改变这一行:
xhr.setRequestHeader ("Authorization", "Basic " + btoa("Bearer:GI3UQr2GYoA.cwA.wHo.h1AyNQKXSESWZGFrf-yf_Cm3XwDRy38Yn-xzgUton-E"));
要:
xhr.setRequestHeader ("Authorization", "Bearer GI3UQr2GYoA.cwA.wHo.h1AyNQKXSESWZGFrf-yf_Cm3XwDRy38Yn-xzgUton-E");
它工作正常!