Reputation: 63
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.
Upvotes: 6
Views: 2872
Reputation: 14609
Read the doc provided by MS about the authentication: https://learn.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!
Upvotes: 7