Android Facebook SDK 3.0 Login Failed - An error has occurred. Please try again later

I am following this tutorial https://developers.facebook.com/docs/howtos/androidsdk/3.0/native-login/ to login. It works with facebook native app, but without native app, first it shows error, then I click OK, then click Login button again, it works. I don't understand why it doesn't work the first time?

android facebook login error

I do not understand what the problem is? This is mistake?

Updated: Here is the code.

    btnFacebook.setOnClickListener(new View.OnClickListener() {

        public void onClick(View view) {
            Session session = Session.getActiveSession();

            if (!session.isOpened() && !session.isClosed()) {
                session.openForRead(new Session.OpenRequest(
                        UserLoginActivity.this).setPermissions(
                        Arrays.asList("basic_info", "email")).setCallback(
                        statusCallback));
            } 
            else {
                Session.openActiveSession(UserLoginActivity.this, true,
                        statusCallback);
            }
        }
    });


        private class SessionStatusCallback implements Session.StatusCallback {
    @Override
    public void call(Session session, SessionState state,
            Exception exception) {
        if (session.isOpened()) {
            final String token = session.getAccessToken();
            Request.executeMeRequestAsync(session,
                    new Request.GraphUserCallback() {
                        @Override
                        public void onCompleted(GraphUser user,
                                Response response) {
                            if (user != null) { 
                                new AsyncFaceLogin(UserLoginActivity.this)
                                .execute(user.getId(),user.getFirstName(),user.getLastName(),(String)user.getProperty("email"),token);
                            }
                        }
                    });
        }
    }
}

      

+3


source to share


1 answer


On the Facebook developer app dashboard page, make sure Sandbox mode is turned off. Alternatively, you can ensure that your App ID and API Key are set correctly in your code.



+4


source







All Articles