ERROR ChatConnector: receive - invalid token. Check bots app ID & Password
After migration my bot from V1 to V3 i get the Error "invalid token. Check bots app ID & Password"
I already create new Application ID and Password and register a new bot on the Bot Framwork webpage. It works with the bot framework channel emulator V3.x
I used then new connection settings for V3
var connector = new builder.ChatConnector({
appId: "appid",
appPassword: "password"
});
var bot = new builder.UniversalBot(connector);
I re-generated the password but I get the same error.
Did you notice that there are now 3 settings in web.config?
<add key="BotId" value="xxxx" />
<add key="MicrosoftAppID" value="yyyyy" />
<add key="MicrosoftAppPassword" value="zzzzzzz" />
i don't have a web.config i used the node.js api and start my bot locally.
I found the problem by myself , there was a timing problem into the jwt and chatconnector lib.
In ChatConnector .js i add a ( +100) . I hope that anybody fix this problem correctly in the future.
if (token) { req.body['useAuth'] = true; this.ensureCachedKeys(function (err, keys) { if (!err) { var decoded = jwt.decode(token, { complete: true });
var now = (new Date().getTime() / 1000)+ 100;
Thanks for noting this. We have some fixes in the works that will address this.
#742
@dandriscoll @Stevenic Please note that is issue is also happening on the CallConnector
Hi @ejadib, we've found the bug and will be fixing it soon. Thanks for raising this.
Has this been resolved? Just today I noticed my bot was no longer working via Twilio (web chat is fine).
@dandriscoll I have this problem in the last version of the BotConnector framework:
// Restify embedded server
var restify = require('restify');
// Microsoft Bot Framework
var BotBuilder = require('botbuilder');
var Config = require('../../config/luis');
// Dialog Intent and Entity objects
var Intent = require('../../dialog/intent');
var IntentFactory = require('../../dialog/intentfactory');
var Entity = require('../../dialog/entity');
var inMemoryStorage = new BotBuilder.MemoryBotStorage();
var connector = new BotBuilder.ChatConnector({
appId: Config[ Config['env'] ].MS_appId,
appPassword: Config[ Config['env'] ].MS_appPass
});
var bot = new BotBuilder.UniversalBot(connector, function (session, args) {
session.send("started up the boiler plate...");
if (!session.userData.notes) {
session.userData.notes = {};
console.log("initializing userData.notes in default message handler");
}
}).set('storage', inMemoryStorage); // Register in memory storage
// Add global LUIS recognizer to bot
bot.recognizer(new BotBuilder.LuisRecognizer(Config[Config['env']].model));
// Joke Intent
bot.dialog(Intent.Type.JokeIntent, [
function (session, args, next) {
var randomMessage = Util.randomElement( Config.locale['en']['JOKES'] );
session.send(randomMessage);
}
]).triggerAction({
matches: Intent.Type.JokeIntent
}).cancelAction('CancelIntent', "Ok.", {
matches: /^(cancel|nevermind)/i
});
var port = process.env.port || 3978;
var server = restify.createServer();
server.post('/bot/api/messages', connector.listen());
server.listen(port, function () {
console.log('%s listening to %s', server.name, server.url);
});
and when I connect to the Bot Emulator I get the ERROR: ChatConnector: receive - invalid token. Requested by unexpected app ID..
I'm pretty sure that my MS appID and appPassword are ok. I have migrated to the latest Bot Frameworks, since I have create a new Bot from scratch few days ago, and tried this simple example.