I have been trying to utilize Azure Direct Line API v3.0 for a bot. However it seems I am no longer enable to start a conversation as I am getting 403 message on APi call. Here is my call:
$.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) {
}
});
Mind you, this used to work couple of days back. I have several activity records for activities created through this API.
But now I am getting this error message constantly on even getting token:
{
"error": {
"code": "BadArgument",
"message": "Missing token or secret"
}
}
I am using free subscription plan and I have 7 days remaining. Also I have checked the subscription status, its active. I have over $140 in credit too.
Please let me know what I am doing wrong and why would this stop working all of a sudden?
Thanks in advance.
Direct Line. This is the standard channel offering of Direct Line. It works by default with bot templates via the Azure portal, bots from the Bot Builder Samples, and bots created with the Azure CLI.
In short, you get the Conversation Id and Service Url when the user installs the bot (personal scope, group chat, or Team channel). You can get it on any message the user sends actually, but getting it when they install the bot on activityUpdate is the best.
Using Direct Line API 3.0, a client can send messages to your bot by issuing HTTP POST requests. A client may send a single message per request. For more information, see Send an activity to the bot.
Azure Bot Service is a cloud platform. It hosts bots and makes them available to channels, such as Microsoft Teams, Facebook, or Slack. The Bot Framework Service, which is a component of the Azure Bot Service, sends information between the user's bot-connected app and the bot.
Read the doc provided by MS about the authentication: 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
It says:
Authorization: Bearer SECRET_OR_TOKEN
So change this line:
xhr.setRequestHeader ("Authorization", "Basic " + btoa("Bearer:GI3UQr2GYoA.cwA.wHo.h1AyNQKXSESWZGFrf-yf_Cm3XwDRy38Yn-xzgUton-E"));
To:
xhr.setRequestHeader ("Authorization", "Bearer GI3UQr2GYoA.cwA.wHo.h1AyNQKXSESWZGFrf-yf_Cm3XwDRy38Yn-xzgUton-E");
And it works fine!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With