Facebook-chat-api: Login Approvoal

Created on 26 Jul 2018  路  8Comments  路  Source: Schmavery/facebook-chat-api

Hi, i'm trying to host my bot on an heroku server, but when i'm trying to connect to my account there is this error :
info login Logging in...
info login You have login approvals turned on.
ERR! login login-approval
Because facebook think that's not me trying to acces to the account. So i tried to use forcelogin (I haven't the 2 factor enable) but it's not working.
login({email: "myEmail", password: "myPassword"},{forceLogin: true}, (err, api) => {}
I think i'm doing something wrong with the option, i don't know how to set the forcelogin.

Thanks you for helping me.

Most helpful comment

Ok so I wrote the output in appstate.json using this command : fs.writeFile('./data.json', JSON.stringify(api.appState, null, 2));
And it's working, I'm able to use my bot on the server ! Thanks you for your help, i'm closing the issue !

All 8 comments

Do you have login approvals turned on for this account? forcelogin doesn't do that much anymore, we should probably remove it from the docs.

No I haven't but when the server where m'y bot is hosted try to connect Facebook block the IP. I Thought force login could resolve this problem.

I guess our heuristic for detecting approvals is a bit off. If you log into the browser I'd imagine you'll see some captcha or something that fb is doing to verify your account. It can be problematic to log in from many locations using heroku or similar. I think some people have had some success logging in using the same session (with api.getAppState)

So I need to log in locally with my browser, save the appState and then use it on the server so he don't need to log in ?

@Dinamots you have to log in locally using facebook-chat-api and save appState
then you will be able to use that save on server

@ravkr Ok thanks a lot :D, gonna try it tomorrow and close the issue if it's a succes :p.
Thanks @ravkr and @Schmavery !

I tried to save what api.getAppState gave me with console.log but I don't know how to use the output, like in your example in a json file but the format is wrong. So how do I save te output of api.appState ?
Sorry, i'm learning nodejs !
Thanks for your help.

Ok so I wrote the output in appstate.json using this command : fs.writeFile('./data.json', JSON.stringify(api.appState, null, 2));
And it's working, I'm able to use my bot on the server ! Thanks you for your help, i'm closing the issue !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MikeShi42 picture MikeShi42  路  9Comments

KuoyuanY picture KuoyuanY  路  7Comments

GEOFBOT picture GEOFBOT  路  4Comments

TKasperczyk picture TKasperczyk  路  5Comments

nripendra picture nripendra  路  8Comments