com.facebook.widget.WebDialog Java Examples

The following examples show how to use com.facebook.widget.WebDialog. 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: AuthorizationClient.java    From facebook-api-android-maven with Apache License 2.0 6 votes vote down vote up
@Override
public WebDialog build() {
    Bundle parameters = getParameters();
    parameters.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, REDIRECT_URI);
    parameters.putString(ServerProtocol.DIALOG_PARAM_CLIENT_ID, getApplicationId());
    parameters.putString(ServerProtocol.DIALOG_PARAM_E2E, e2e);
    parameters.putString(ServerProtocol.DIALOG_PARAM_RESPONSE_TYPE, ServerProtocol.DIALOG_RESPONSE_TYPE_TOKEN);
    parameters.putString(ServerProtocol.DIALOG_PARAM_RETURN_SCOPES, ServerProtocol.DIALOG_RETURN_SCOPES_TRUE);

    // Only set the rerequest auth type for non legacy requests
    if (isRerequest && !Settings.getPlatformCompatibilityEnabled()) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_AUTH_TYPE, ServerProtocol.DIALOG_REREQUEST_AUTH_TYPE);
    }

    return new WebDialog(getContext(), OAUTH_DIALOG, parameters, getTheme(), getListener());
}
 
Example #2
Source File: AuthorizationClient.java    From android-skeleton-project with MIT License 6 votes vote down vote up
@Override
public WebDialog build() {
    Bundle parameters = getParameters();
    parameters.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, REDIRECT_URI);
    parameters.putString(ServerProtocol.DIALOG_PARAM_CLIENT_ID, getApplicationId());
    parameters.putString(ServerProtocol.DIALOG_PARAM_E2E, e2e);
    parameters.putString(ServerProtocol.DIALOG_PARAM_RESPONSE_TYPE, ServerProtocol.DIALOG_RESPONSE_TYPE_TOKEN);
    parameters.putString(ServerProtocol.DIALOG_PARAM_RETURN_SCOPES, ServerProtocol.DIALOG_RETURN_SCOPES_TRUE);

    // Only set the rerequest auth type for non legacy requests
    if (isRerequest && !Settings.getPlatformCompatibilityEnabled()) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_AUTH_TYPE, ServerProtocol.DIALOG_REREQUEST_AUTH_TYPE);
    }

    return new WebDialog(getContext(), OAUTH_DIALOG, parameters, getTheme(), getListener());
}
 
Example #3
Source File: AuthorizationClient.java    From Abelana-Android with Apache License 2.0 6 votes vote down vote up
@Override
public WebDialog build() {
    Bundle parameters = getParameters();
    parameters.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, REDIRECT_URI);
    parameters.putString(ServerProtocol.DIALOG_PARAM_CLIENT_ID, getApplicationId());
    parameters.putString(ServerProtocol.DIALOG_PARAM_E2E, e2e);
    parameters.putString(ServerProtocol.DIALOG_PARAM_RESPONSE_TYPE, ServerProtocol.DIALOG_RESPONSE_TYPE_TOKEN);
    parameters.putString(ServerProtocol.DIALOG_PARAM_RETURN_SCOPES, ServerProtocol.DIALOG_RETURN_SCOPES_TRUE);

    // Only set the rerequest auth type for non legacy requests
    if (isRerequest && !Settings.getPlatformCompatibilityEnabled()) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_AUTH_TYPE, ServerProtocol.DIALOG_REREQUEST_AUTH_TYPE);
    }

    return new WebDialog(getContext(), OAUTH_DIALOG, parameters, getTheme(), getListener());
}
 
Example #4
Source File: AuthorizationClient.java    From FacebookImageShareIntent with MIT License 6 votes vote down vote up
@Override
public WebDialog build() {
    Bundle parameters = getParameters();
    parameters.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, REDIRECT_URI);
    parameters.putString(ServerProtocol.DIALOG_PARAM_CLIENT_ID, getApplicationId());
    parameters.putString(ServerProtocol.DIALOG_PARAM_E2E, e2e);
    parameters.putString(ServerProtocol.DIALOG_PARAM_RESPONSE_TYPE, ServerProtocol.DIALOG_RESPONSE_TYPE_TOKEN);
    parameters.putString(ServerProtocol.DIALOG_PARAM_RETURN_SCOPES, ServerProtocol.DIALOG_RETURN_SCOPES_TRUE);

    // Only set the rerequest auth type for non legacy requests
    if (isRerequest && !Settings.getPlatformCompatibilityEnabled()) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_AUTH_TYPE, ServerProtocol.DIALOG_REREQUEST_AUTH_TYPE);
    }

    return new WebDialog(getContext(), OAUTH_DIALOG, parameters, getTheme(), getListener());
}
 
Example #5
Source File: AuthorizationClient.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 5 votes vote down vote up
@Override
boolean tryAuthorize(final AuthorizationRequest request) {
    String applicationId = request.getApplicationId();
    Bundle parameters = new Bundle();
    if (!Utility.isNullOrEmpty(request.getPermissions())) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_SCOPE, TextUtils.join(",", request.getPermissions()));
    }

    String previousToken = request.getPreviousAccessToken();
    if (!Utility.isNullOrEmpty(previousToken) && (previousToken.equals(loadCookieToken()))) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousToken);
    } else {
        // The call to clear cookies will create the first instance of CookieSyncManager if necessary
        Utility.clearFacebookCookies(context);
    }

    WebDialog.OnCompleteListener listener = new WebDialog.OnCompleteListener() {
        @Override
        public void onComplete(Bundle values, FacebookException error) {
            onWebDialogComplete(request, values, error);
        }
    };

    WebDialog.Builder builder =
            new AuthDialogBuilder(getStartActivityDelegate().getActivityContext(), applicationId, parameters)
                    .setOnCompleteListener(listener);
    loginDialog = builder.build();
    loginDialog.show();

    return true;
}
 
Example #6
Source File: AuthorizationClient.java    From FacebookNewsfeedSample-Android with Apache License 2.0 5 votes vote down vote up
@Override
public WebDialog build() {
    Bundle parameters = getParameters();
    parameters.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, REDIRECT_URI);
    parameters.putString(ServerProtocol.DIALOG_PARAM_CLIENT_ID, getApplicationId());

    return new WebDialog(getContext(), OAUTH_DIALOG, parameters, getTheme(), getListener());
}
 
Example #7
Source File: AuthorizationClient.java    From FacebookNewsfeedSample-Android with Apache License 2.0 5 votes vote down vote up
@Override
boolean tryAuthorize(final AuthorizationRequest request) {
    String applicationId = request.getApplicationId();
    Bundle parameters = new Bundle();
    if (!Utility.isNullOrEmpty(request.getPermissions())) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_SCOPE, TextUtils.join(",", request.getPermissions()));
    }

    String previousToken = request.getPreviousAccessToken();
    if (!Utility.isNullOrEmpty(previousToken) && (previousToken.equals(loadCookieToken()))) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousToken);
    } else {
        // The call to clear cookies will create the first instance of CookieSyncManager if necessary
        Utility.clearFacebookCookies(context);
    }

    WebDialog.OnCompleteListener listener = new WebDialog.OnCompleteListener() {
        @Override
        public void onComplete(Bundle values, FacebookException error) {
            onWebDialogComplete(request, values, error);
        }
    };

    WebDialog.Builder builder =
            new AuthDialogBuilder(getStartActivityDelegate().getActivityContext(), applicationId, parameters)
                    .setOnCompleteListener(listener);
    loginDialog = builder.build();
    loginDialog.show();

    return true;
}
 
Example #8
Source File: AuthorizationClient.java    From HypFacebook with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public WebDialog build() {
    Bundle parameters = getParameters();
    parameters.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, REDIRECT_URI);
    parameters.putString(ServerProtocol.DIALOG_PARAM_CLIENT_ID, getApplicationId());

    return new WebDialog(getContext(), OAUTH_DIALOG, parameters, getTheme(), getListener());
}
 
Example #9
Source File: AuthorizationClient.java    From HypFacebook with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
boolean tryAuthorize(final AuthorizationRequest request) {
    String applicationId = request.getApplicationId();
    Bundle parameters = new Bundle();
    if (!Utility.isNullOrEmpty(request.getPermissions())) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_SCOPE, TextUtils.join(",", request.getPermissions()));
    }

    String previousToken = request.getPreviousAccessToken();
    if (!Utility.isNullOrEmpty(previousToken) && (previousToken.equals(loadCookieToken()))) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousToken);
    } else {
        // The call to clear cookies will create the first instance of CookieSyncManager if necessary
        Utility.clearFacebookCookies(context);
    }

    WebDialog.OnCompleteListener listener = new WebDialog.OnCompleteListener() {
        @Override
        public void onComplete(Bundle values, FacebookException error) {
            onWebDialogComplete(request, values, error);
        }
    };

    WebDialog.Builder builder =
            new AuthDialogBuilder(getStartActivityDelegate().getActivityContext(), applicationId, parameters)
                    .setOnCompleteListener(listener);
    loginDialog = builder.build();
    loginDialog.show();

    return true;
}
 
Example #10
Source File: AuthorizationClient.java    From KlyphMessenger with MIT License 5 votes vote down vote up
@Override
public WebDialog build() {
    Bundle parameters = getParameters();
    parameters.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, REDIRECT_URI);
    parameters.putString(ServerProtocol.DIALOG_PARAM_CLIENT_ID, getApplicationId());
    parameters.putString(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    return new WebDialog(getContext(), OAUTH_DIALOG, parameters, getTheme(), getListener());
}
 
Example #11
Source File: AuthorizationClient.java    From KlyphMessenger with MIT License 5 votes vote down vote up
@Override
boolean tryAuthorize(final AuthorizationRequest request) {
    applicationId = request.getApplicationId();
    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);
    }

    String previousToken = request.getPreviousAccessToken();
    if (!Utility.isNullOrEmpty(previousToken) && (previousToken.equals(loadCookieToken()))) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousToken);
        // 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(context);
        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 = getE2E();
    addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    WebDialog.Builder builder =
            new AuthDialogBuilder(getStartActivityDelegate().getActivityContext(), applicationId, parameters)
                    .setE2E(e2e)
                    .setOnCompleteListener(listener);
    loginDialog = builder.build();
    loginDialog.show();

    return true;
}
 
Example #12
Source File: AuthorizationClient.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 5 votes vote down vote up
@Override
public WebDialog build() {
    Bundle parameters = getParameters();
    parameters.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, REDIRECT_URI);
    parameters.putString(ServerProtocol.DIALOG_PARAM_CLIENT_ID, getApplicationId());

    return new WebDialog(getContext(), OAUTH_DIALOG, parameters, getTheme(), getListener());
}
 
Example #13
Source File: AuthorizationClient.java    From platform-friends-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
boolean tryAuthorize(final AuthorizationRequest request) {
    applicationId = request.getApplicationId();
    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);
    }

    String previousToken = request.getPreviousAccessToken();
    if (!Utility.isNullOrEmpty(previousToken) && (previousToken.equals(loadCookieToken()))) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousToken);
        // 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(context);
        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 = getE2E();
    addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    WebDialog.Builder builder =
            new AuthDialogBuilder(getStartActivityDelegate().getActivityContext(), applicationId, parameters)
                    .setE2E(e2e)
                    .setOnCompleteListener(listener);
    loginDialog = builder.build();
    loginDialog.show();

    return true;
}
 
Example #14
Source File: AuthorizationClient.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
@Override
public WebDialog build() {
    Bundle parameters = getParameters();
    parameters.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, REDIRECT_URI);
    parameters.putString(ServerProtocol.DIALOG_PARAM_CLIENT_ID, getApplicationId());
    parameters.putString(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    return new WebDialog(getContext(), OAUTH_DIALOG, parameters, getTheme(), getListener());
}
 
Example #15
Source File: AuthorizationClient.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
@Override
boolean tryAuthorize(final AuthorizationRequest request) {
    applicationId = request.getApplicationId();
    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);
    }

    String previousToken = request.getPreviousAccessToken();
    if (!Utility.isNullOrEmpty(previousToken) && (previousToken.equals(loadCookieToken()))) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousToken);
        // 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(context);
        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 = getE2E();
    addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    WebDialog.Builder builder =
            new AuthDialogBuilder(getStartActivityDelegate().getActivityContext(), applicationId, parameters)
                    .setE2E(e2e)
                    .setOnCompleteListener(listener);
    loginDialog = builder.build();
    loginDialog.show();

    return true;
}
 
Example #16
Source File: AuthorizationClient.java    From Klyph with MIT License 5 votes vote down vote up
@Override
public WebDialog build() {
    Bundle parameters = getParameters();
    parameters.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, REDIRECT_URI);
    parameters.putString(ServerProtocol.DIALOG_PARAM_CLIENT_ID, getApplicationId());
    parameters.putString(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    return new WebDialog(getContext(), OAUTH_DIALOG, parameters, getTheme(), getListener());
}
 
Example #17
Source File: AuthorizationClient.java    From Klyph with MIT License 5 votes vote down vote up
@Override
boolean tryAuthorize(final AuthorizationRequest request) {
    applicationId = request.getApplicationId();
    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);
    }

    String previousToken = request.getPreviousAccessToken();
    if (!Utility.isNullOrEmpty(previousToken) && (previousToken.equals(loadCookieToken()))) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousToken);
        // 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(context);
        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 = getE2E();
    addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    WebDialog.Builder builder =
            new AuthDialogBuilder(getStartActivityDelegate().getActivityContext(), applicationId, parameters)
                    .setE2E(e2e)
                    .setOnCompleteListener(listener);
    loginDialog = builder.build();
    loginDialog.show();

    return true;
}
 
Example #18
Source File: AuthorizationClient.java    From platform-friends-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public WebDialog build() {
    Bundle parameters = getParameters();
    parameters.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, REDIRECT_URI);
    parameters.putString(ServerProtocol.DIALOG_PARAM_CLIENT_ID, getApplicationId());
    parameters.putString(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    return new WebDialog(getContext(), OAUTH_DIALOG, parameters, getTheme(), getListener());
}
 
Example #19
Source File: AuthorizationClient.java    From Abelana-Android with Apache License 2.0 4 votes vote down vote up
@Override
boolean tryAuthorize(final AuthorizationRequest request) {
    applicationId = request.getApplicationId();
    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);
    }

    SessionDefaultAudience audience = request.getDefaultAudience();
    parameters.putString(ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE, audience.getNativeProtocolAudience());

    String previousToken = request.getPreviousAccessToken();
    if (!Utility.isNullOrEmpty(previousToken) && (previousToken.equals(loadCookieToken()))) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousToken);
        // 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(context);
        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 = getE2E();
    addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    WebDialog.Builder builder =
            new AuthDialogBuilder(getStartActivityDelegate().getActivityContext(), applicationId, parameters)
                    .setE2E(e2e)
                    .setIsRerequest(request.isRerequest())
                    .setOnCompleteListener(listener);
    loginDialog = builder.build();
    loginDialog.show();

    return true;
}
 
Example #20
Source File: AuthorizationClient.java    From FacebookImageShareIntent with MIT License 4 votes vote down vote up
@Override
boolean tryAuthorize(final AuthorizationRequest request) {
    applicationId = request.getApplicationId();
    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);
    }

    String previousToken = request.getPreviousAccessToken();
    if (!Utility.isNullOrEmpty(previousToken) && (previousToken.equals(loadCookieToken()))) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousToken);
        // 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(context);
        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 = getE2E();
    addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    WebDialog.Builder builder =
            new AuthDialogBuilder(getStartActivityDelegate().getActivityContext(), applicationId, parameters)
                    .setE2E(e2e)
                    .setIsRerequest(request.isRerequest())
                    .setOnCompleteListener(listener);
    loginDialog = builder.build();
    loginDialog.show();

    return true;
}
 
Example #21
Source File: AuthorizationClient.java    From android-skeleton-project with MIT License 4 votes vote down vote up
@Override
boolean tryAuthorize(final AuthorizationRequest request) {
    applicationId = request.getApplicationId();
    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);
    }

    String previousToken = request.getPreviousAccessToken();
    if (!Utility.isNullOrEmpty(previousToken) && (previousToken.equals(loadCookieToken()))) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousToken);
        // 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(context);
        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 = getE2E();
    addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    WebDialog.Builder builder =
            new AuthDialogBuilder(getStartActivityDelegate().getActivityContext(), applicationId, parameters)
                    .setE2E(e2e)
                    .setIsRerequest(request.isRerequest())
                    .setOnCompleteListener(listener);
    loginDialog = builder.build();
    loginDialog.show();

    return true;
}
 
Example #22
Source File: AuthorizationClient.java    From facebook-api-android-maven with Apache License 2.0 4 votes vote down vote up
@Override
boolean tryAuthorize(final AuthorizationRequest request) {
    applicationId = request.getApplicationId();
    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);
    }

    SessionDefaultAudience audience = request.getDefaultAudience();
    parameters.putString(ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE, audience.getNativeProtocolAudience());

    String previousToken = request.getPreviousAccessToken();
    if (!Utility.isNullOrEmpty(previousToken) && (previousToken.equals(loadCookieToken()))) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousToken);
        // 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(context);
        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 = getE2E();
    addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    WebDialog.Builder builder =
            new AuthDialogBuilder(getStartActivityDelegate().getActivityContext(), applicationId, parameters)
                    .setE2E(e2e)
                    .setIsRerequest(request.isRerequest())
                    .setOnCompleteListener(listener);
    loginDialog = builder.build();
    loginDialog.show();

    return true;
}
 
Example #23
Source File: UserTimeline.java    From Klyph with MIT License 4 votes vote down vote up
private void publishFeedDialog()
{
	Bundle params = new Bundle();
	params.putString("from", KlyphSession.getSessionUserId());
	params.putString("to", getElementId());

	WebDialog feedDialog = (new WebDialog.FeedDialogBuilder(getActivity(), Session.getActiveSession(), params)).setOnCompleteListener(
			new WebDialog.OnCompleteListener() {

				@Override
				public void onComplete(Bundle values, FacebookException error)
				{
					if (error == null)
					{
						final String postId = values.getString("post_id");

						if (postId != null)
						{
							Toast.makeText(getActivity(), R.string.message_successfully_published, Toast.LENGTH_SHORT).show();

							loadNewest();
						}
						else
						{
							// User clicked the Cancel button
							Toast.makeText(getActivity().getApplicationContext(), "Publish cancelled", Toast.LENGTH_SHORT).show();
						}
					}
					else if (error instanceof FacebookOperationCanceledException)
					{
						// User clicked the "x" button
						// Toast.makeText(getActivity().getApplicationContext(),
						// "Publish cancelled",
						// Toast.LENGTH_SHORT).show();
					}
					else
					{
						AlertUtil.showAlert(getActivity(), R.string.error, R.string.publish_message_unknown_error, R.string.ok);
					}
				}

			}).build();
	feedDialog.show();
}