private void openSession(String applicationId, List<String> permissions, SessionLoginBehavior behavior, int activityCode, SessionAuthorizationType authType) { if (sessionTracker != null) { Session currentSession = sessionTracker.getSession(); if (currentSession == null || currentSession.getState().isClosed()) { Session session = new Session.Builder(getActivity()).setApplicationId(applicationId).build(); Session.setActiveSession(session); currentSession = session; } if (!currentSession.isOpened()) { Session.OpenRequest openRequest = new Session.OpenRequest(this). setPermissions(permissions). setLoginBehavior(behavior). setRequestCode(activityCode); if (SessionAuthorizationType.PUBLISH.equals(authType)) { currentSession.openForPublish(openRequest); } else { currentSession.openForRead(openRequest); } } } }
private void authorize(Activity paramActivity, String[] paramArrayOfString, int paramInt, SessionLoginBehavior paramSessionLoginBehavior, final DialogListener paramDialogListener) { checkUserSession("authorize"); this.pendingOpeningSession = new Session.Builder(paramActivity).setApplicationId(this.mAppId).setTokenCachingStrategy(getTokenCache()).build(); this.pendingAuthorizationActivity = paramActivity; String[] arrayOfString; if (paramArrayOfString != null) arrayOfString = paramArrayOfString; else arrayOfString = new String[0]; this.pendingAuthorizationPermissions = arrayOfString; Session.StatusCallback local1 = new Session.StatusCallback() { public void call(Session paramAnonymousSession, SessionState paramAnonymousSessionState, Exception paramAnonymousException) { Facebook.this.onSessionCallback(paramAnonymousSession, paramAnonymousSessionState, paramAnonymousException, paramDialogListener); } }; Session.OpenRequest localOpenRequest = new Session.OpenRequest(paramActivity).setCallback(local1).setLoginBehavior(paramSessionLoginBehavior).setRequestCode(paramInt).setPermissions(Arrays.asList(this.pendingAuthorizationPermissions)); Session localSession = this.pendingOpeningSession; boolean bool; if (this.pendingAuthorizationPermissions.length > 0) bool = true; else bool = false; openSession(localSession, localOpenRequest, bool); }
@Deprecated public void authorize(Activity paramActivity, String[] paramArrayOfString, int paramInt, DialogListener paramDialogListener) { SessionLoginBehavior localSessionLoginBehavior; if (paramInt >= 0) localSessionLoginBehavior = SessionLoginBehavior.SSO_WITH_FALLBACK; else localSessionLoginBehavior = SessionLoginBehavior.SUPPRESS_SSO; authorize(paramActivity, paramArrayOfString, paramInt, localSessionLoginBehavior, paramDialogListener); }
@MediumTest @LargeTest public void testCanSetParametersViaLayout() throws Throwable { TestActivity activity = getActivity(); assertNotNull(activity); final UserSettingsFragment fragment = activity.getFragment(); assertNotNull(fragment); assertEquals(SessionLoginBehavior.SUPPRESS_SSO, fragment.getLoginBehavior()); assertEquals(SessionDefaultAudience.EVERYONE, fragment.getDefaultAudience()); List<String> permissions = fragment.getPermissions(); assertEquals(2, permissions.size()); assertEquals("read_1", permissions.get(0)); }
public void setLoginBehavior(SessionLoginBehavior loginBehavior) { this.loginBehavior = loginBehavior; }
public SessionLoginBehavior getLoginBehavior() { return loginBehavior; }
@Deprecated public void authorize(Activity paramActivity, DialogListener paramDialogListener) { authorize(paramActivity, new String[0], 32665, SessionLoginBehavior.SSO_WITH_FALLBACK, paramDialogListener); }
protected final void openSessionForPublish(String paramString, List<String> paramList) { openSessionForPublish(paramString, paramList, SessionLoginBehavior.SSO_WITH_FALLBACK, 64206); }
protected final void openSessionForRead(String paramString, List<String> paramList, SessionLoginBehavior paramSessionLoginBehavior, int paramInt) { openSession(paramString, paramList, paramSessionLoginBehavior, paramInt, SessionAuthorizationType.READ); }
public SessionLoginBehavior getLoginBehavior() { return this.properties.getLoginBehavior(); }
/** * Full authorize method. * <p/> * Starts either an Activity or a dialog which prompts the user to log in to * Facebook and grant the requested permissions to the given application. * <p/> * This method will, when possible, use Facebook's single sign-on for * Android to obtain an access token. This involves proxying a call through * the Facebook for Android stand-alone application, which will handle the * authentication flow, and return an OAuth access token for making API * calls. * <p/> * Because this process will not be available for all users, if single * sign-on is not possible, this method will automatically fall back to the * OAuth 2.0 User-Agent flow. In this flow, the user credentials are handled * by Facebook in an embedded WebView, not by the client application. As * such, the dialog makes a network request and renders HTML content rather * than a native UI. The access token is retrieved from a redirect to a * special URL that the WebView handles. * <p/> * Note that User credentials could be handled natively using the OAuth 2.0 * Username and Password Flow, but this is not supported by this SDK. * <p/> * See http://developers.facebook.com/docs/authentication/ and * http://wiki.oauth.net/OAuth-2 for more details. * <p/> * Note that this method is asynchronous and the callback will be invoked in * the original calling thread (not in a background thread). * <p/> * Also note that requests may be made to the API without calling authorize * first, in which case only public information is returned. * <p/> * IMPORTANT: Note that single sign-on authentication will not function * correctly if you do not include a call to the authorizeCallback() method * in your onActivityResult() function! Please see below for more * information. single sign-on may be disabled by passing FORCE_DIALOG_AUTH * as the activityCode parameter in your call to authorize(). * <p/> * This method is deprecated. See {@link com.facebook.android.Facebook} and {@link Session} for more info. * * @param activity * The Android activity in which we want to display the * authorization dialog. * @param permissions * A list of permissions required for this application: e.g. * "read_stream", "publish_stream", "offline_access", etc. see * http://developers.facebook.com/docs/authentication/permissions * This parameter should not be null -- if you do not require any * permissions, then pass in an empty String array. * @param activityCode * Single sign-on requires an activity result to be called back * to the client application -- if you are waiting on other * activities to return data, pass a custom activity code here to * avoid collisions. If you would like to force the use of legacy * dialog-based authorization, pass FORCE_DIALOG_AUTH for this * parameter. Otherwise just omit this parameter and Facebook * will use a suitable default. See * http://developer.android.com/reference/android/ * app/Activity.html for more information. * @param listener * Callback interface for notifying the calling application when * the authentication dialog has completed, failed, or been * canceled. */ @Deprecated public void authorize(Activity activity, String[] permissions, int activityCode, final DialogListener listener) { SessionLoginBehavior behavior = (activityCode >= 0) ? SessionLoginBehavior.SSO_WITH_FALLBACK : SessionLoginBehavior.SUPPRESS_SSO; authorize(activity, permissions, activityCode, behavior, listener); }
/** * Opens a new session with read permissions. If either applicationID or permissions * is null, this method will default to using the values from the associated * meta-data value and an empty list respectively. * * @param applicationId the applicationID, can be null * @param permissions the permissions list, can be null */ protected final void openSessionForRead(String applicationId, List<String> permissions) { openSessionForRead(applicationId, permissions, SessionLoginBehavior.SSO_WITH_FALLBACK, Session.DEFAULT_AUTHORIZE_ACTIVITY_CODE); }
/** * Opens a new session with read permissions. If either applicationID or permissions * is null, this method will default to using the values from the associated * meta-data value and an empty list respectively. * * @param applicationId the applicationID, can be null * @param permissions the permissions list, can be null * @param behavior the login behavior to use with the session * @param activityCode the activity code to use for the SSO activity */ protected final void openSessionForRead(String applicationId, List<String> permissions, SessionLoginBehavior behavior, int activityCode) { openSession(applicationId, permissions, behavior, activityCode, SessionAuthorizationType.READ); }