Question

I have an app where users can log in using Facebook. I'm using the LoginButton class from the Facebook SDK. The login and logout works fine, but every time the user tries to login (after he has logged out) he is asked for granting permissions. The expected behavior (and it's behaving like this on iOS) is that Facebook only asks once for permissions, and in all subsequent logins it won't ask for that.

LoginButton in layout:

<com.facebook.widget.LoginButton
            xmlns:fb="http://schemas.android.com/apk/res-auto"

            android:id="@+id/facebookLoginButton"

            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            android:layout_gravity="center"
            android:layout_marginTop="30dp"

            fb:login_text="@string/login_with_facebook"
            fb:logout_text="@string/logout_with_facebook"/>

My activity code:

FacebookSessionStatusChangedListener sessionCallback = new
        FacebookSessionStatusChangedListener();

facebookLoginButton.setOnErrorListener(new FacebookLoginButtonErrorListener());
facebookLoginButton.setReadPermissions(FacebookConfiguration.PERMISSIONS);
facebookLoginButton.setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK);
facebookLoginButton.setSessionStatusCallback(sessionCallback);

private class FacebookSessionStatusChangedListener implements Session
        .StatusCallback {
    ...
}

private class FacebookLoginButtonErrorListener implements LoginButton.OnErrorListener {
    ...
}
Was it helpful?

Solution

I finally found the reason for this: The permissions were incorrect! I had a typo in my permissions and therewith asked for permissions Facebook did not know about (user_actions:videos).

After correcting these the login goes without asking and asking again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top