jaxbot / hangouts-bot

Node.js hangouts code
44 stars 14 forks source link

How to fix XMPP authentication failure #12

Closed mike1011 closed 6 years ago

mike1011 commented 6 years ago

Below is my code in nodejs.

var hangoutsBot = require("hangouts-bot");
const xmpp = require('node-xmpp');
var fs = require('fs');
var path = require('path');
var credentials = JSON.parse(fs.readFileSync(path.join(__dirname, "credentials.json")));

var bot = new hangoutsBot(credentials.email, credentials.password);

bot.on('online', function() {
    console.log('online');
});

bot.on('message', function(from, message) {
    console.log(from + ">> " + message);
});

bot.on('message', function(from, message) {
    console.log(from + ">> " + message);

    switch (message) {
        case "help":
            bot.sendMessage(from, "I an example Hangouts bot. Try saying hello.");
            break;
        case "hello":
            bot.sendMessage(from, "Why hello to you too.");
            break;
    }
});

Why i am getting authentication failure...despite of correct creds being used.Kindly help.?

anthonyjlmorel commented 6 years ago

I don't know if that can help for you, but I had a similar connection issue. It was related to the fact that google refuses connection from "less secure app" (meaning, those that does not use OAuth). Try to disable this and see ?

tambu22 commented 6 years ago

I have this issue and it's because google considers the connection as suspicious activity and refuses it, despite having the "allow less secure apps" option enabled.