fbchat-dev / fbchat

Facebook Chat (Messenger) for Python
https://fbchat.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.19k stars 412 forks source link

Cannot login from virtual private server #225

Closed truenicoco closed 7 years ago

truenicoco commented 7 years ago

I've written a very basic bot to transmit facebook messages to my cell phone by SMS using my cell provider API.

Unfortunately I can only use it from my laptop and every time I try to connect from my OVH virtual private server, it raises some security alert on Facebook, forcing me to change my password even though I tell facebook that I was the one to login.

I'm not sure it can be fixed in this awesome project's code, but figured I'll share this issue anyway. Who knows, there might be a fix…

madsmtm commented 7 years ago

Guessing it's a security protection mechanism enforced by Facebook. Maybe they recognise the OVH server's IP as malicious, maybe it's just the fact that the server is in another country, but I don't think it's anything we can fix. If possible (I don't know how OVH works), try to see if you can login with a browser from their servers?

truenicoco commented 7 years ago

Well I tried to login using w3m through SSH on my OVH VPS, and despite my using the right password:

Too Many Login Attempts
It looks like you're having trouble accessing your account. To protect your security, we've temporarily blocked anyone from logging. For help, we recommending contacting your trusted contacts.

Funny thing is, I did not receive any warning in my logged sessions. I guess OVH IP's are blocked. It used to work…

Thanks for your help anyway!

TimLChan commented 7 years ago

Try VPN in when you're using a "trusted device", e.g VPN in on your desktop while you're already logged in and see if it kicks you out. If it does, you can then log-in again and clear the security checkpoints.

Alternatively, change the sleep time below to something like 10-15s, which should allow you to clear the checkpoint (and hopefully not require you to reset your password). https://github.com/carpedm20/fbchat/blob/7ecf229db568b6fcd3873d37f2df80ae1f1a929b/fbchat/client.py#L385

truenicoco commented 7 years ago

This sounds like a great idea. Right now I'm struggling to understand how to set up a VPN on VPS…

truenicoco commented 7 years ago

And it did work. Thanks @TimLChan!