com.facebook.login.LoginResult Java Examples
The following examples show how to use
com.facebook.login.LoginResult.
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 File: Login.java From UberClone with MIT License | 7 votes |
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 File: LoginFragment.java From HaiNaBaiChuan with Apache License 2.0 | 6 votes |
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 #3
Source File: FacebookHelper.java From AndroidBlueprints with Apache License 2.0 | 6 votes |
/** * 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 #4
Source File: FacebookHelper.java From AndroidBlueprints with Apache License 2.0 | 6 votes |
/** * 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 #5
Source File: FacebookHelper.java From social-login-helper-Deprecated- with MIT License | 6 votes |
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 File: FireSignin.java From Learning-Resources with MIT License | 6 votes |
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 #7
Source File: LoginActivity.java From social-app-android with Apache License 2.0 | 6 votes |
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 #8
Source File: AccountNavigator.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
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 #9
Source File: LoginPresenter.java From HaiNaBaiChuan with Apache License 2.0 | 6 votes |
@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 #10
Source File: FacebookNetwork.java From EasyLogin with MIT License | 6 votes |
@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 #11
Source File: FacebookAuth.java From edx-app-android with Apache License 2.0 | 6 votes |
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 #12
Source File: Login.java From UberClone with MIT License | 6 votes |
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 #13
Source File: LoginActivity.java From social-app-android with Apache License 2.0 | 6 votes |
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 #14
Source File: UserServiceAndroidExtra.java From Android-SDK with MIT License | 6 votes |
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 File: FaceBookManager.java From FimiX8-RE with MIT License | 5 votes |
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 File: FbLoginHiddenActivity.java From SocialLoginManager with Apache License 2.0 | 5 votes |
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 #17
Source File: FbLoginHiddenActivity.java From SocialLoginManager with Apache License 2.0 | 5 votes |
@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 #18
Source File: LoginInteractorImpl.java From Saude-no-Mapa with MIT License | 5 votes |
@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 #19
Source File: LoginDialogFragment.java From openshop.io-android with MIT License | 5 votes |
@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 #20
Source File: MainActivity.java From ExamplesAndroid with Apache License 2.0 | 5 votes |
@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 #21
Source File: AndroidGDXFacebook.java From gdx-facebook with Apache License 2.0 | 5 votes |
@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 #22
Source File: FacebookSignInHandler.java From FirebaseUI-Android with Apache License 2.0 | 5 votes |
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 #23
Source File: FacebookSignInHandler.java From FirebaseUI-Android with Apache License 2.0 | 5 votes |
@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(); }
Example #24
Source File: LoginActivity.java From android with MIT License | 5 votes |
private void setupFacebookLogin() { facebookCallbackManager = CallbackManager.Factory.create(); vFacebookButton.setReadPermissions(getResources().getString(R.string.facebook_permissions)); vFacebookButton.registerCallback(facebookCallbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { final String token = loginResult.getAccessToken().getToken(); runSocialLoginTask(Const.ApiValues.OAUTH_TYPE_FACEBOOK, token); } @Override public void onCancel() { } @Override public void onError(FacebookException error) { try { final String message = String.format( getResources().getString(R.string.snackbar_auth_error_facebook), error.getMessage() ); RedSnackbar.make(findViewById(R.id.root_view), message, Snackbar.LENGTH_LONG) .show(); } catch (NullPointerException e) { e.printStackTrace(); } } }); vFacebookButton.setTypeface(TypefaceHelper.getTypeface(this, Const.TypeFaces.REGULAR)); }
Example #25
Source File: BaseAuthActivity.java From q-municate-android with Apache License 2.0 | 5 votes |
@Override public void onSuccess(LoginResult loginResult) { Log.d(TAG, "+++ FacebookCallback call onSuccess from BaseAuthActivity +++"); showProgress(); serviceManager.login(QBProvider.FACEBOOK, loginResult.getAccessToken().getToken(), null) .subscribe(socialLoginObserver); }
Example #26
Source File: LoginActivity.java From Simple-Blog-App with MIT License | 5 votes |
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 #27
Source File: LoginPresenter.java From social-app-android with Apache License 2.0 | 5 votes |
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 #28
Source File: FacebookSignUpActivity.java From socialmediasignup with MIT License | 5 votes |
@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 #29
Source File: FacebookHelper.java From argus-android with Apache License 2.0 | 5 votes |
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 #30
Source File: LoginPresenter.java From social-app-android with Apache License 2.0 | 5 votes |
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); }); }