Java Code Examples for com.facebook.login.LoginResult

The following examples show how to use com.facebook.login.LoginResult. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: UberClone   Source File: Login.java    License: MIT License 7 votes vote down vote up
private void setupFacebookStuff() {

        // This should normally be on your application class
        FacebookSdk.sdkInitialize(getApplicationContext());

        mLoginManager = LoginManager.getInstance();
        mFacebookCallbackManager = CallbackManager.Factory.create();

        LoginManager.getInstance().registerCallback(mFacebookCallbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                //login
                firebaseHelper.registerByFacebookAccount();
            }

            @Override
            public void onCancel() {
                Toast.makeText(Login.this,"The login was canceled",Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onError(FacebookException error) {
                Toast.makeText(Login.this,"There was an error in the login",Toast.LENGTH_SHORT).show();
            }
        });
    }
 
Example 2
Source Project: social-app-android   Source File: LoginActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void initFacebookSignIn() {
    mCallbackManager = CallbackManager.Factory.create();
    LoginManager.getInstance().registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            LogUtil.logDebug(TAG, "facebook:onSuccess:" + loginResult);
            presenter.handleFacebookSignInResult(loginResult);
        }

        @Override
        public void onCancel() {
            LogUtil.logDebug(TAG, "facebook:onCancel");
        }

        @Override
        public void onError(FacebookException error) {
            LogUtil.logError(TAG, "facebook:onError", error);
            showSnackBar(error.getMessage());
        }
    });

    findViewById(R.id.facebookSignInButton).setOnClickListener(v -> presenter.onFacebookSignInClick());
}
 
Example 3
Source Project: UberClone   Source File: Login.java    License: MIT License 6 votes vote down vote up
private void setupFacebookStuff() {

        // This should normally be on your application class
        FacebookSdk.sdkInitialize(getApplicationContext());

        mLoginManager = LoginManager.getInstance();
        mFacebookCallbackManager = CallbackManager.Factory.create();

        LoginManager.getInstance().registerCallback(mFacebookCallbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                //login
                firebaseHelper.registerByFacebookAccount();
            }

            @Override
            public void onCancel() {
                Toast.makeText(Login.this,"The login was canceled",Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onError(FacebookException error) {
                Toast.makeText(Login.this,"There was an error in the login",Toast.LENGTH_SHORT).show();
            }
        });
    }
 
Example 4
Source Project: EasyLogin   Source File: FacebookNetwork.java    License: MIT License 6 votes vote down vote up
@Override
public void onSuccess(LoginResult loginResult) {

    final AccessToken fbAccessToken = loginResult.getAccessToken();

    if (permissions.contains(EMAIL_PERMISSION_FIELD)) {
        addEmailToToken(fbAccessToken);
        return;
    }

    String token = fbAccessToken.getToken();
    String userId = fbAccessToken.getUserId();
    accessToken = new com.maksim88.easylogin.AccessToken.Builder(token)
            .userId(userId)
            .build();
    listener.onLoginSuccess(getNetwork());
}
 
Example 5
Source Project: social-login-helper-Deprecated-   Source File: FacebookHelper.java    License: MIT License 6 votes vote down vote up
public FacebookHelper(@NonNull FacebookListener facebookListener) {
  mListener = facebookListener;
  mCallBackManager = CallbackManager.Factory.create();
  FacebookCallback<LoginResult> mCallBack = new FacebookCallback<LoginResult>() {
    @Override public void onSuccess(LoginResult loginResult) {
      mListener.onFbSignInSuccess(loginResult.getAccessToken().getToken(),
          loginResult.getAccessToken().getUserId());
    }

    @Override public void onCancel() {
      mListener.onFbSignInFail("User cancelled operation");
    }

    @Override public void onError(FacebookException e) {
      mListener.onFbSignInFail(e.getMessage());
    }
  };
  LoginManager.getInstance().registerCallback(mCallBackManager, mCallBack);
}
 
Example 6
Source Project: AndroidBlueprints   Source File: FacebookHelper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Register call back manager.
 *
 * @param activity the activity
 */
private void registerCallBackManager(final Activity activity) {
    LoginManager.getInstance()
            .registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
                @Override
                public void onSuccess(LoginResult loginResult) {
                    mLoginResult = loginResult;
                    getUserProfile(activity);
                }

                @Override
                public void onCancel() {
                    mFacebookLoginResultCallBack.onFacebookLoginCancel();
                }

                @Override
                public void onError(FacebookException error) {
                    mFacebookLoginResultCallBack.onFacebookLoginError(error);
                }
            });
}
 
Example 7
Source Project: AndroidBlueprints   Source File: FacebookHelper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Register call back manager to Google log in button.
 *
 * @param activity    the activity
 * @param loginButton the login button
 */
private void registerCallBackManager(final Activity activity, LoginButton loginButton) {
    loginButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            mLoginResult = loginResult;
            getUserProfile(activity);
        }

        @Override
        public void onCancel() {
            mFacebookLoginResultCallBack.onFacebookLoginCancel();
        }

        @Override
        public void onError(FacebookException error) {
            mFacebookLoginResultCallBack.onFacebookLoginError(error);
        }
    });
}
 
Example 8
Source Project: social-app-android   Source File: LoginActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void initFacebookSignIn() {
    mCallbackManager = CallbackManager.Factory.create();
    LoginManager.getInstance().registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            LogUtil.logDebug(TAG, "facebook:onSuccess:" + loginResult);
            presenter.handleFacebookSignInResult(loginResult);
        }

        @Override
        public void onCancel() {
            LogUtil.logDebug(TAG, "facebook:onCancel");
        }

        @Override
        public void onError(FacebookException error) {
            LogUtil.logError(TAG, "facebook:onError", error);
            showSnackBar(error.getMessage());
        }
    });

    findViewById(R.id.facebookSignInButton).setOnClickListener(v -> presenter.onFacebookSignInClick());
}
 
Example 9
Source Project: HaiNaBaiChuan   Source File: LoginFragment.java    License: Apache License 2.0 6 votes vote down vote up
private void initFaceBookLogin() {
    callbackManager = CallbackManager.Factory.create();
    btnLoginFacebook.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            showDialog();
            presenter.requestFacebook(loginResult);
            LogUtil.e2(loginResult.getAccessToken().toString());
        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError(FacebookException error) {

        }
    });
}
 
Example 10
Source Project: HaiNaBaiChuan   Source File: LoginPresenter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void requestFacebook(LoginResult loginResult) {
    AccessToken accessToken = loginResult.getAccessToken();
    NetRequest.Instance().facebookLogin(accessToken.getUserId(), MD5Util.getMD5(accessToken.getUserId()),
            new NetRequest.RequestListener<User>() {
                @Override
                public void success(User user) {
                    view.callLoginSuccess();
                }

                @Override
                public void error(String err) {
                    view.callLoginFail(err);
                }
            });

}
 
Example 11
public void navigateToFacebookSignUpForResult(Collection<String> permissions) {
  facebookLoginManager.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
    @Override public void onSuccess(LoginResult loginResult) {
      facebookLoginSubject.call(
          new FacebookLoginResult(loginResult, FacebookLoginResult.STATE_SUCCESS, null));
    }

    @Override public void onCancel() {
      facebookLoginSubject.call(
          new FacebookLoginResult(null, FacebookLoginResult.STATE_CANCELLED, null));
    }

    @Override public void onError(FacebookException error) {
      facebookLoginSubject.call(
          new FacebookLoginResult(null, FacebookLoginResult.STATE_ERROR, error));
    }
  });
  facebookLoginManager.logInWithReadPermissions(activityNavigator.getActivity(), permissions);
}
 
Example 12
Source Project: Learning-Resources   Source File: FireSignin.java    License: MIT License 6 votes vote down vote up
private void signInFacebook() {

        mPrgrsbrMain.setVisibility(View.VISIBLE);
        LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("public_profile", "email"));
        LoginManager.getInstance().registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {

                // Facebook Sign In was successful, authenticate with Firebase
                firebaseAuthWithFacebook(loginResult.getAccessToken());
            }

            @Override
            public void onCancel() {
                LogManager.printLog(LOGTYPE_DEBUG, "facebook:onCancel");
                mPrgrsbrMain.setVisibility(View.GONE);
            }

            @Override
            public void onError(FacebookException error) {
                Log.d(LOG_TAG, "facebook:onError", error);
                mPrgrsbrMain.setVisibility(View.GONE);
            }
        });
    }
 
Example 13
Source Project: edx-app-android   Source File: FacebookAuth.java    License: Apache License 2.0 6 votes vote down vote up
public FacebookAuth(Activity activity) {
    super(activity);
    callbackManager = CallbackManager.Factory.create();
    LoginManager.getInstance().registerCallback(callbackManager,
            new FacebookCallback<LoginResult>() {
                @Override
                public void onSuccess(LoginResult loginResult) {
                    if (callback != null) {
                        callback.onLogin(loginResult.getAccessToken().getToken());
                    }
                    logger.debug("Facebook Logged in successfully.");
                }

                @Override
                public void onCancel() {
                    logger.debug("Facebook Log in canceled.");
                }

                @Override
                public void onError(FacebookException error) {
                    logger.error(error);
                }
            });
}
 
Example 14
Source Project: Android-SDK   Source File: UserServiceAndroidExtra.java    License: MIT License 6 votes vote down vote up
void loginWithFacebookSdk( final android.app.Activity context, final Map<String, String> facebookFieldsMappings,
                           List<String> permissions, CallbackManager callbackManager, final AsyncCallback<BackendlessUser> responder )
{
  LoginManager.getInstance().registerCallback( callbackManager, new FacebookCallback<LoginResult>()
  {
    @Override
    public void onSuccess( LoginResult loginResult )
    {
      getBackendlessUser( loginResult.getAccessToken(), facebookFieldsMappings, responder );
    }

    @Override
    public void onCancel()
    {
      responder.handleFault( new BackendlessFault( ExceptionMessage.FACEBOOK_LOGINNING_CANCELED ) );
    }

    @Override
    public void onError( FacebookException exception )
    {
      responder.handleFault( new BackendlessFault( ExceptionMessage.NULL_GRAPH_USER ) );
       }
     } );

  LoginManager.getInstance().logInWithReadPermissions( context, permissions );
}
 
Example 15
Source Project: FimiX8-RE   Source File: FaceBookManager.java    License: MIT License 5 votes vote down vote up
public void login(Context context, final LoginCallback callback) {
    this.loginCallback = callback;
    this.mCallbackManager = Factory.create();
    FacebookSdk.sdkInitialize(context);
    this.loginManager = LoginManager.getInstance();
    this.loginManager.registerCallback(this.mCallbackManager, new FacebookCallback<LoginResult>() {
        public void onSuccess(LoginResult loginResult) {
            GraphRequest.newMeRequest(loginResult.getAccessToken(), new GraphJSONObjectCallback() {
                public void onCompleted(JSONObject object, GraphResponse response) {
                    Log.i(FaceBookManager.TAG, "onCompleted: ");
                    if (object != null) {
                        Map<String, String> map = new HashMap();
                        map.put("name", object.optString("name"));
                        map.put(BlockInfo.KEY_UID, object.optString("id"));
                        FaceBookManager.this.loginCallback.loginSuccess(map);
                    }
                }
            }).executeAsync();
        }

        public void onCancel() {
            Log.i(FaceBookManager.TAG, "onCancel: ");
        }

        public void onError(FacebookException error) {
            Log.i(FaceBookManager.TAG, "onError: ");
            callback.loginFail(error.getMessage());
        }
    });
    LoginManager.getInstance().logInWithReadPermissions((Activity) context, Arrays.asList(new String[]{"public_profile", "user_friends"}));
}
 
Example 16
Source Project: social-app-android   Source File: LoginPresenter.java    License: Apache License 2.0 5 votes vote down vote up
public void handleFacebookSignInResult(LoginResult loginResult) {
    ifViewAttached(view -> {
        LogUtil.logDebug(TAG, "handleFacebookSignInResult: " + loginResult);
        view.setProfilePhotoUrl(buildFacebookPhotoUrl(loginResult.getAccessToken().getUserId()));
        view.showProgress();
        AuthCredential credential = FacebookAuthProvider.getCredential(loginResult.getAccessToken().getToken());
        view.firebaseAuthWithCredentials(credential);
    });
}
 
Example 17
Source Project: socialmediasignup   Source File: FacebookSignUpActivity.java    License: MIT License 5 votes vote down vote up
@Override
public void onSuccess(LoginResult loginResult) {
    startLoading();
    GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(), this);
    Bundle parameters = new Bundle();
    parameters.putString("fields", "id,name,email,link");
    request.setParameters(parameters);
    request.executeAsync();
}
 
Example 18
Source Project: argus-android   Source File: FacebookHelper.java    License: Apache License 2.0 5 votes vote down vote up
public void initialize() {
    LoginManager.getInstance()
            .registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
                @Override
                public void onSuccess(LoginResult loginResult) {

                    GraphRequest graphRequest = GraphRequest
                            .newMeRequest(loginResult.getAccessToken(),
                                    new GraphRequest.GraphJSONObjectCallback() {
                                        @Override
                                        public void onCompleted(JSONObject object,
                                                                GraphResponse response) {
                                            token = AccessToken.getCurrentAccessToken();
                                            if (resultListener != null) {
                                                resultListener.onSuccess(token);
                                            }
                                        }
                                    });
                    Bundle parameters = new Bundle();
                    graphRequest.setParameters(parameters);
                    graphRequest.executeAsync();
                }

                @Override
                public void onCancel() {
                }

                @Override
                public void onError(FacebookException error) {
                    resultListener.onFailure(error.getMessage());
                }
            });
}
 
Example 19
Source Project: android-paypal-example   Source File: LoginActivity.java    License: Apache License 2.0 5 votes vote down vote up
@OnClick(R.id.fb_login)
public void setUpFacebookLoginButton() {
    LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("email", "public_profile"));
    LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            handleFacebookAccessToken(loginResult.getAccessToken());
        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError(FacebookException error) {
            if(!isNetworkConnected()){
                Snackbar.make(findViewById(android.R.id.content),"please check internet connection"
                        ,Snackbar.LENGTH_SHORT).show();
            }else{
                Snackbar.make(findViewById(android.R.id.content),"unexpected error,please try again later"
                        ,Snackbar.LENGTH_SHORT).show();
            }
        }
    });
}
 
Example 20
Source Project: FeedFire   Source File: FacebookSign.java    License: MIT License 5 votes vote down vote up
public void signIn(){
    List<String> permissionNeeds= Arrays.asList("email", "public_profile");
    LoginManager.getInstance().logInWithReadPermissions(
            mActivity,
            permissionNeeds);
    LoginManager.getInstance().registerCallback(mCallbackManager,
            new FacebookCallback<LoginResult>() {
                @Override
                public void onSuccess(LoginResult loginResults) {
                    handleFacebookAccessToken(loginResults.getAccessToken());
                }

                @Override
                public void onCancel() {
                    if (mFaceCallback != null){
                        mFaceCallback.cancelLoginFace();
                    }
                }

                @Override
                public void onError(FacebookException e) {
                    if (mFaceCallback != null){
                        mFaceCallback.errorLoginFace( e );
                    }
                }
            });
}
 
Example 21
Source Project: social-app-android   Source File: LoginPresenter.java    License: Apache License 2.0 5 votes vote down vote up
public void handleFacebookSignInResult(LoginResult loginResult) {
    ifViewAttached(view -> {
        LogUtil.logDebug(TAG, "handleFacebookSignInResult: " + loginResult);
        view.setProfilePhotoUrl(buildFacebookPhotoUrl(loginResult.getAccessToken().getUserId()));
        view.showProgress();
        AuthCredential credential = FacebookAuthProvider.getCredential(loginResult.getAccessToken().getToken());
        view.firebaseAuthWithCredentials(credential);
    });
}
 
Example 22
Source Project: Simple-Blog-App   Source File: LoginActivity.java    License: MIT License 5 votes vote down vote up
private void fbInit() {

        FacebookSdk.sdkInitialize(getApplicationContext());
        callbackManager = CallbackManager.Factory.create();
        LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                Log.d("facebook:token", AccessToken.getCurrentAccessToken().getToken());
                AccessToken.getCurrentAccessToken().getToken();
                signInWithFacebook(loginResult.getAccessToken());
            }

            @Override
            public void onCancel() {
                Log.d(TAG, "facebook:onCancel");
            }

            @Override
            public void onError(FacebookException error) {
                Log.d(TAG, "facebook:onError", error);
            }
        });
        fbImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                LoginManager.getInstance().logInWithReadPermissions(LoginActivity.this, Arrays.asList("email", "user_location", "user_birthday", "public_profile", "user_friends"));
            }
        });
    }
 
Example 23
Source Project: SocialLoginManager   Source File: FbLoginHiddenActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onSuccess(LoginResult loginResult) {
  if (!SocialLoginManager.getInstance(this).isWithProfile()) {
    handleLoginSuccess(loginResult);
    finish();
    return;
  }

  GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(), this);
  Bundle parameters = new Bundle();
  parameters.putString("fields", "id,name,email,link");
  request.setParameters(parameters);
  request.executeAsync();
}
 
Example 24
Source Project: SocialLoginManager   Source File: FbLoginHiddenActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void handleLoginSuccess(LoginResult result) {
  SocialUser user = new SocialUser();
  user.userId = result.getAccessToken().getUserId();
  user.accessToken = result.getAccessToken().getToken();
  user.photoUrl = String.format(PHOTO_URL, user.userId);
  SocialLoginManager.getInstance(this).onLoginSuccess(user);
}
 
Example 25
Source Project: Saude-no-Mapa   Source File: LoginInteractorImpl.java    License: MIT License 5 votes vote down vote up
@Override
public void requestLoginToFacebook(List<String> permissions, FacebookCallback<LoginResult> callback) {
    mCallbackmanager = CallbackManager.Factory.create();
    LoginManager.getInstance()
            .logInWithReadPermissions((LoginActivity) mContext, permissions);
    LoginManager.getInstance()
            .registerCallback(mCallbackmanager, callback);
}
 
Example 26
Source Project: openshop.io-android   Source File: LoginDialogFragment.java    License: MIT License 5 votes vote down vote up
@Override
public void onSuccess(final LoginResult loginResult) {
    Timber.d("FB login success");
    if (loginResult == null) {
        Timber.e("Fb login succeed with null loginResult.");
        handleNonFatalError(getString(R.string.Facebook_login_failed), true);
    } else {
        Timber.d("Result: %s", loginResult.toString());
        GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(),
                new GraphRequest.GraphJSONObjectCallback() {
                    @Override
                    public void onCompleted(JSONObject object, GraphResponse response) {
                        if (response != null && response.getError() == null) {
                            verifyUserOnApi(object, loginResult.getAccessToken());
                        } else {
                            Timber.e("Error on receiving user profile information.");
                            if (response != null && response.getError() != null) {
                                Timber.e(new RuntimeException(), "Error: %s", response.getError().toString());
                            }
                            handleNonFatalError(getString(R.string.Receiving_facebook_profile_failed), true);
                        }
                    }
                });
        Bundle parameters = new Bundle();
        parameters.putString("fields", "id,name,email,gender");
        request.setParameters(parameters);
        request.executeAsync();
    }
}
 
Example 27
Source Project: ExamplesAndroid   Source File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //--------------------------------------------//
    FacebookSdk.sdkInitialize(this);//El SDK necesita ser inicializado antes de usar cualquiera de sus métodos,pasando el contexto de la actividad(Activity)
    callbackManager = CallbackManager.Factory.create();//inizializamos el CallbackManager
    //---------------------------------------------//
    setContentView(R.layout.activity_main);

    info = (TextView) findViewById(R.id.info);
    loginButton = (LoginButton) findViewById(R.id.login_button);
    //--------------------------------------------------//

    loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {//Si la autenticacion fue correcta
            info.setText("Login attempt success.");

        }

        @Override
        public void onCancel() {//Si se cancela la solicitus de login
            info.setText("Login attempt canceled.");
        }

        @Override
        public void onError(FacebookException e) {//Si ocurre un error
            info.setText("Login attempt failed.");
        }
    });
}
 
Example 28
Source Project: gdx-facebook   Source File: AndroidGDXFacebook.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void startGUISignIn() {
    Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Starting GUI sign in.");
    LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {

        @Override
        public void onSuccess(LoginResult loginResult) {
            accessToken = new GDXFacebookAccessToken(AccessToken.getCurrentAccessToken().getToken(), AccessToken.getCurrentAccessToken().getExpires().getTime());
            storeNewToken(accessToken);
            Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Sign in successful. User token: " + accessToken.getToken());
            callback.onSuccess(new SignInResult(accessToken, "Sign in successful."));
        }

        @Override
        public void onCancel() {
            Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Sign fail by user.");
            callback.onCancel();
        }

        @Override
        public void onError(FacebookException e) {
            Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Error while trying to sign in: " + e.getMessage());
            callback.onError(new GDXFacebookError(e.getMessage()));
        }
    });

    if (this.signInMode == SignInMode.PUBLISH) {
        LoginManager.getInstance().logInWithPublishPermissions(activity, gdxArrayToCollection(permissions));
    } else {
        LoginManager.getInstance().logInWithReadPermissions(activity, gdxArrayToCollection(permissions));
    }
}
 
Example 29
Source Project: FirebaseUI-Android   Source File: FacebookSignInHandler.java    License: Apache License 2.0 5 votes vote down vote up
private static IdpResponse createIdpResponse(
        LoginResult result, @Nullable String email, String name, Uri photoUri) {
    return new IdpResponse.Builder(
            new User.Builder(FacebookAuthProvider.PROVIDER_ID, email)
                    .setName(name)
                    .setPhotoUri(photoUri)
                    .build())
            .setToken(result.getAccessToken().getToken())
            .build();
}
 
Example 30
Source Project: FirebaseUI-Android   Source File: FacebookSignInHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onSuccess(LoginResult result) {
    setResult(Resource.<IdpResponse>forLoading());

    GraphRequest request = GraphRequest.newMeRequest(result.getAccessToken(),
            new ProfileRequest(result));

    Bundle parameters = new Bundle();
    parameters.putString("fields", "id,name,email,picture");
    request.setParameters(parameters);
    request.executeAsync();
}