@Override boolean tryAuthorize(final LoginClient.Request request) { Bundle parameters = new Bundle(); if (!Utility.isNullOrEmpty(request.getPermissions())) { String scope = TextUtils.join(",", request.getPermissions()); parameters.putString(ServerProtocol.DIALOG_PARAM_SCOPE, scope); addLoggingExtra(ServerProtocol.DIALOG_PARAM_SCOPE, scope); } DefaultAudience audience = request.getDefaultAudience(); parameters.putString( ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE, audience.getNativeProtocolAudience()); AccessToken previousToken = AccessToken.getCurrentAccessToken(); String previousTokenString = previousToken != null ? previousToken.getToken() : null; if (previousTokenString != null && (previousTokenString.equals(loadCookieToken()))) { parameters.putString( ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousTokenString); // Don't log the actual access token, just its presence or absence. addLoggingExtra( ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, AppEventsConstants.EVENT_PARAM_VALUE_YES); } else { // The call to clear cookies will create the first instance of CookieSyncManager if // necessary Utility.clearFacebookCookies(loginClient.getActivity()); addLoggingExtra( ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, AppEventsConstants.EVENT_PARAM_VALUE_NO); } WebDialog.OnCompleteListener listener = new WebDialog.OnCompleteListener() { @Override public void onComplete(Bundle values, FacebookException error) { onWebDialogComplete(request, values, error); } }; e2e = LoginClient.getE2E(); addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e); FragmentActivity fragmentActivity = loginClient.getActivity(); WebDialog.Builder builder = new AuthDialogBuilder( fragmentActivity, request.getApplicationId(), parameters) .setE2E(e2e) .setIsRerequest(request.isRerequest()) .setOnCompleteListener(listener) .setTheme(FacebookSdk.getWebDialogTheme()); loginDialog = builder.build(); FacebookDialogFragment dialogFragment = new FacebookDialogFragment(); dialogFragment.setRetainInstance(true); dialogFragment.setDialog(loginDialog); dialogFragment.show(fragmentActivity.getSupportFragmentManager(), FacebookDialogFragment.TAG); return true; }
@Override boolean tryAuthorize(final LoginClient.Request request) { Bundle parameters = new Bundle(); if (!Utility.isNullOrEmpty(request.getPermissions())) { String scope = TextUtils.join(",", request.getPermissions()); parameters.putString(ServerProtocol.DIALOG_PARAM_SCOPE, scope); addLoggingExtra(ServerProtocol.DIALOG_PARAM_SCOPE, scope); } DefaultAudience audience = request.getDefaultAudience(); parameters.putString( ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE, audience.getNativeProtocolAudience()); AccessToken previousToken = AccessToken.getCurrentAccessToken(); String previousTokenString = previousToken != null ? previousToken.getToken() : null; if (previousTokenString != null && (previousTokenString.equals(loadCookieToken()))) { parameters.putString( ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousTokenString); // Don't log the actual access token, just its presence or absence. addLoggingExtra( ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, AppEventsConstants.EVENT_PARAM_VALUE_YES); } else { // The call to clear cookies will create the first instance of CookieSyncManager if // necessary Utility.clearFacebookCookies(loginClient.getActivity()); addLoggingExtra( ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, AppEventsConstants.EVENT_PARAM_VALUE_NO); } WebDialog.OnCompleteListener listener = new WebDialog.OnCompleteListener() { @Override public void onComplete(Bundle values, FacebookException error) { onWebDialogComplete(request, values, error); } }; e2e = LoginClient.getE2E(); addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e); FragmentActivity fragmentActivity = loginClient.getActivity(); WebDialog.Builder builder = new AuthDialogBuilder( fragmentActivity, request.getApplicationId(), parameters) .setE2E(e2e) .setIsRerequest(request.isRerequest()) .setOnCompleteListener(listener); loginDialog = builder.build(); FacebookDialogFragment dialogFragment = new FacebookDialogFragment(); dialogFragment.setRetainInstance(true); dialogFragment.setDialog(loginDialog); dialogFragment.show(fragmentActivity.getSupportFragmentManager(), FacebookDialogFragment.TAG); return true; }