gave92 / fbchat-sharp

Facebook Messenger client library for C#

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Facebook locks the account although I use Cookie sessions

ahmed605 opened this issue · comments

Facebook locks my account although I use Cookie sessions to login every time the app opened with Client.TryLogin() method

So the login works when you use username and pw but not on subsequent tries with cookies?

I've received reports of Facebook locking the account but I could not track down the problem. If you're willing, enabling 2 factor authentication on your FB account seems to be of help.

the login works with the both ways after re-unlocking my FB account. I mean is there a way to use client without re-logging every time I open the app

Client.TryLogin() should do just that, no need to use username and pw after the first time (just don't call Client.DoLogout()). It should be ok calling Client.TryLogin() every time you open your app.

I'm already using Client.TryLogin()

And what happens? The login fails? With what error?

after logging many times with Client.TryLogin() (to test code changes) the facebook locked the account then the Client.TryLogin() returns false but after re-unlocking the account the tryLogin() works but I mean is there a way to use client without re-logging every time I open the app

OK you may try adding this function to your implementation of MessengerClient. This just loads the cookies without connecting to https://www.facebook.com/login to check is they're valid.

public new async Task<bool> TryLogin()
{
    try
    {
        var session_cookies = await this.ReadCookiesFromDiskAsync();
        await base.setSession(session_cookies);
        return true;
    }
    catch (Exception ex)
    {
        this.Log(ex.ToString());
        return false;
    }
}

Not sure it will work, FB only locks my account when not using sessions cookies. When doing multiple logins to test code changes, logging in to facebook through browser (and going through the procedure of verifying suspicious logins) once in a while may also be of help.

Thx I got it