Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Facebook SDK 4.0 Login without Facebook App

I'm having issues with the webview login for Facebook on Android.

I've followed the tutorials and login works perfectly when the user has the Facebook app installed. When the Facebook app is not installed, the webview for facebook login pops up; however, after logging in and accepting the permissions, the webview simply redirects back to the login screen. It never goes back to my app.

Has anyone else encountered this problem?

    FacebookSdk.sdkInitialize(this);
    profileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(Profile profile, Profile profile2) {
            if (profile2 != null) {
                loggedIn(profile2);
            } else {
                loggedOut();
            }
        }
    };
    accessTokenTracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(AccessToken accessToken, AccessToken accessToken2) {
            Profile.fetchProfileForCurrentAccessToken();
        }
    };
    callbackManager = CallbackManager.Factory.create();
    LoginManager.getInstance().registerCallback(callbackManager,
            new FacebookCallback<LoginResult>() {
                @Override
                public void onSuccess(LoginResult loginResult) {
                    // App code
                    getProfileInfo();
                }

                @Override
                public void onCancel() {
                    // App code
                    Log.e("Facebook Login", "Login Cancelled");
                    loggedOut();
                }

                @Override
                public void onError(FacebookException exception) {
                    // App code
                    Log.e("Facebook Login", "Failed to Login " + exception.toString());
                    loggedOut();
                }
            });

Looking at the logs without filters while the login takes place, I see a couple of possibly relevant logs.

I/chromium﹕ [INFO:CONSOLE(0)] "event.returnValue is deprecated. Please use the standard event.preventDefault() instead.", source:  (0)
I/Auth.Core﹕ [TokenCache] Missing snowballing token: no granted scopes set.
like image 996
sihrc Avatar asked May 02 '15 06:05

sihrc


People also ask

How do I integrate Facebook SDK?

Configure Your Facebook App for Android First, log into Facebook developer account and do the following: Go to the App Dashboard; Click My Apps and create a new app; Go to Settings > Basic to see the App Details Panel with your App ID, App Secret as well as other app details.


1 Answers

What was causing the problem was that I was overriding the onclicklistener of the login button to call the login function of the LoginManager. Just don't.

like image 161
sihrc Avatar answered Oct 03 '22 03:10

sihrc