com.facebook.internal.ServerProtocol Java Examples

The following examples show how to use com.facebook.internal.ServerProtocol. 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 FacebookNewsfeedSample-Android with Apache License 2.0 6 votes vote down vote up
private Result handleResultOk(Intent data) {
    Bundle extras = data.getExtras();
    String error = extras.getString("error");
    if (error == null) {
        error = extras.getString("error_type");
    }

    if (error == null) {
        AccessToken token = AccessToken.createFromWebBundle(pendingRequest.getPermissions(), extras,
                AccessTokenSource.FACEBOOK_APPLICATION_WEB);
        return Result.createTokenResult(token);
    } else if (ServerProtocol.errorsProxyAuthDisabled.contains(error)) {
        return null;
    } else if (ServerProtocol.errorsUserCanceled.contains(error)) {
        return Result.createCancelResult(null);
    } else {
        return Result.createErrorResult(error, extras.getString("error_description"));
    }
}
 
Example #2
Source File: WebViewLoginMethodHandler.java    From kognitivo 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_AND_SIGNED_REQUEST);
    parameters.putString(
            ServerProtocol.DIALOG_PARAM_RETURN_SCOPES,
            ServerProtocol.DIALOG_RETURN_SCOPES_TRUE);

    // Set the re-request auth type for requests
    if (isRerequest) {
        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: KatanaProxyLoginMethodHandler.java    From kognitivo with Apache License 2.0 6 votes vote down vote up
@Override
boolean tryAuthorize(LoginClient.Request request) {
    String e2e = LoginClient.getE2E();
    Intent intent = NativeProtocol.createProxyAuthIntent(
            loginClient.getActivity(),
            request.getApplicationId(),
            request.getPermissions(),
            e2e,
            request.isRerequest(),
            request.hasPublishPermission(),
            request.getDefaultAudience());

    addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    return tryIntent(intent, LoginClient.getLoginRequestCode());
}
 
Example #4
Source File: KatanaProxyLoginMethodHandler.java    From kognitivo with Apache License 2.0 6 votes vote down vote up
private LoginClient.Result handleResultCancel(LoginClient.Request request, Intent data) {
    Bundle extras = data.getExtras();
    String error = getError(extras);
    String errorCode = extras.getString("error_code");

    // If the device has lost network, the result will be a cancel with a connection failure
    // error. We want our consumers to be notified of this as an error so they can tell their
    // users to "reconnect and try again".
    if (ServerProtocol.errorConnectionFailure.equals(errorCode)) {
        String errorMessage = getErrorMessage(extras);

        return LoginClient.Result.createErrorResult(request, error, errorMessage, errorCode);
    }

    return LoginClient.Result.createCancelResult(request, error);
}
 
Example #5
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 #6
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 #7
Source File: AuthorizationClient.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 6 votes vote down vote up
private Result handleResultOk(Intent data) {
    Bundle extras = data.getExtras();
    String error = extras.getString("error");
    if (error == null) {
        error = extras.getString("error_type");
    }

    if (error == null) {
        AccessToken token = AccessToken.createFromWebBundle(pendingRequest.getPermissions(), extras,
                AccessTokenSource.FACEBOOK_APPLICATION_WEB);
        return Result.createTokenResult(token);
    } else if (ServerProtocol.errorsProxyAuthDisabled.contains(error)) {
        return null;
    } else if (ServerProtocol.errorsUserCanceled.contains(error)) {
        return Result.createCancelResult(null);
    } else {
        return Result.createErrorResult(error, extras.getString("error_description"));
    }
}
 
Example #8
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 #9
Source File: RequestTests.java    From FacebookImageShareIntent with MIT License 6 votes vote down vote up
@SmallTest
@MediumTest
@LargeTest
public void testSingleGetToHttpRequest() throws Exception {
    Request requestMe = new Request(null, "TourEiffel");
    HttpURLConnection connection = Request.toHttpConnection(requestMe);

    assertTrue(connection != null);

    assertEquals("GET", connection.getRequestMethod());
    assertEquals("/" + ServerProtocol.getAPIVersion() + "/TourEiffel", connection.getURL().getPath());

    assertTrue(connection.getRequestProperty("User-Agent").startsWith("FBAndroidSDK"));

    Uri uri = Uri.parse(connection.getURL().toString());
    assertEquals("android", uri.getQueryParameter("sdk"));
    assertEquals("json", uri.getQueryParameter("format"));
}
 
Example #10
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 #11
Source File: AuthorizationClient.java    From HypFacebook with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private Result handleResultOk(Intent data) {
    Bundle extras = data.getExtras();
    String error = extras.getString("error");
    if (error == null) {
        error = extras.getString("error_type");
    }

    if (error == null) {
        AccessToken token = AccessToken.createFromWebBundle(pendingRequest.getPermissions(), extras,
                AccessTokenSource.FACEBOOK_APPLICATION_WEB);
        return Result.createTokenResult(token);
    } else if (ServerProtocol.errorsProxyAuthDisabled.contains(error)) {
        return null;
    } else if (ServerProtocol.errorsUserCanceled.contains(error)) {
        return Result.createCancelResult(null);
    } else {
        return Result.createErrorResult(error, extras.getString("error_description"));
    }
}
 
Example #12
Source File: LikeActionController.java    From kognitivo with Apache License 2.0 6 votes vote down vote up
protected void setRequest(GraphRequest request) {
    this.request = request;
    // Make sure that our requests are hitting the latest version of the API known to this
    // sdk.
    request.setVersion(ServerProtocol.GRAPH_API_VERSION);
    request.setCallback(new GraphRequest.Callback() {
        @Override
        public void onCompleted(GraphResponse response) {
            error = response.getError();
            if (error != null) {
                processError(error);
            } else {
                processSuccess(response);
            }
        }
    });
}
 
Example #13
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 #14
Source File: Request.java    From HypFacebook with BSD 2-Clause "Simplified" License 5 votes vote down vote up
final String getUrlForBatchedRequest() {
    if (overriddenURL != null) {
        throw new FacebookException("Can't override URL for a batch request");
    }

    String baseUrl;
    if (this.restMethod != null) {
        baseUrl = ServerProtocol.BATCHED_REST_METHOD_URL_BASE + this.restMethod;
    } else {
        baseUrl = this.graphPath;
    }

    addCommonParameters();
    return appendParametersToBaseUrl(baseUrl);
}
 
Example #15
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 #16
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 #17
Source File: Request.java    From HypFacebook with BSD 2-Clause "Simplified" License 5 votes vote down vote up
final String getUrlForSingleRequest() {
    if (overriddenURL != null) {
        return overriddenURL.toString();
    }

    String baseUrl;
    if (this.restMethod != null) {
        baseUrl = ServerProtocol.REST_URL_BASE + this.restMethod;
    } else {
        baseUrl = ServerProtocol.GRAPH_URL_BASE + this.graphPath;
    }

    addCommonParameters();
    return appendParametersToBaseUrl(baseUrl);
}
 
Example #18
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 #19
Source File: WebDialog.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a WebDialog using the parameters provided. The dialog is not shown,
 * but is ready to be shown by calling Dialog.show().
 *
 * @return the WebDialog
 */
public WebDialog build() {
    if (session != null && session.isOpened()) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_APP_ID, session.getApplicationId());
        parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, session.getAccessToken());
    } else {
        parameters.putString(ServerProtocol.DIALOG_PARAM_APP_ID, applicationId);
    }

    return new WebDialog(context, action, parameters, theme, listener);
}
 
Example #20
Source File: AuthorizationClient.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
private Result handleResultOk(Intent data) {
    Bundle extras = data.getExtras();
    String error = extras.getString("error");
    if (error == null) {
        error = extras.getString("error_type");
    }
    String errorCode = extras.getString("error_code");
    String errorMessage = extras.getString("error_message");
    if (errorMessage == null) {
        errorMessage = extras.getString("error_description");
    }

    String e2e = extras.getString(NativeProtocol.FACEBOOK_PROXY_AUTH_E2E_KEY);
    if (!Utility.isNullOrEmpty(e2e)) {
        logWebLoginCompleted(applicationId, e2e);
    }

    if (error == null && errorCode == null && errorMessage == null) {
        AccessToken token = AccessToken.createFromWebBundle(pendingRequest.getPermissions(), extras,
                AccessTokenSource.FACEBOOK_APPLICATION_WEB);
        return Result.createTokenResult(pendingRequest, token);
    } else if (ServerProtocol.errorsProxyAuthDisabled.contains(error)) {
        return null;
    } else if (ServerProtocol.errorsUserCanceled.contains(error)) {
        return Result.createCancelResult(pendingRequest, null);
    } else {
        return Result.createErrorResult(pendingRequest, error, errorMessage, errorCode);
    }
}
 
Example #21
Source File: AuthorizationClient.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
@Override
boolean tryAuthorize(AuthorizationRequest request) {
    applicationId = request.getApplicationId();

    String e2e = getE2E();
    Intent intent = NativeProtocol.createProxyAuthIntent(context, request.getApplicationId(),
            request.getPermissions(), e2e, request.isRerequest(), request.getDefaultAudience());

    addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    return tryIntent(intent, request.getRequestCode());
}
 
Example #22
Source File: WebDialog.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a WebDialog using the parameters provided. The dialog is not shown,
 * but is ready to be shown by calling Dialog.show().
 *
 * @return the WebDialog
 */
public WebDialog build() {
    if (session != null && session.isOpened()) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_APP_ID, session.getApplicationId());
        parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, session.getAccessToken());
    } else {
        parameters.putString(ServerProtocol.DIALOG_PARAM_APP_ID, applicationId);
    }

    if (!parameters.containsKey(ServerProtocol.DIALOG_PARAM_REDIRECT_URI)) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, REDIRECT_URI);
    }

    return new WebDialog(context, action, parameters, theme, listener);
}
 
Example #23
Source File: Request.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 5 votes vote down vote up
final String getUrlForSingleRequest() {
    if (overriddenURL != null) {
        return overriddenURL.toString();
    }

    String baseUrl;
    if (this.restMethod != null) {
        baseUrl = ServerProtocol.REST_URL_BASE + this.restMethod;
    } else {
        baseUrl = ServerProtocol.GRAPH_URL_BASE + this.graphPath;
    }

    addCommonParameters();
    return appendParametersToBaseUrl(baseUrl);
}
 
Example #24
Source File: Request.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 5 votes vote down vote up
final String getUrlForBatchedRequest() {
    if (overriddenURL != null) {
        throw new FacebookException("Can't override URL for a batch request");
    }

    String baseUrl;
    if (this.restMethod != null) {
        baseUrl = ServerProtocol.BATCHED_REST_METHOD_URL_BASE + this.restMethod;
    } else {
        baseUrl = this.graphPath;
    }

    addCommonParameters();
    return appendParametersToBaseUrl(baseUrl);
}
 
Example #25
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 #26
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 #27
Source File: KatanaProxyLoginMethodHandler.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
private LoginClient.Result handleResultOk(LoginClient.Request request, Intent data) {
    Bundle extras = data.getExtras();
    String error = getError(extras);
    String errorCode = extras.getString("error_code");
    String errorMessage = getErrorMessage(extras);

    String e2e = extras.getString(NativeProtocol.FACEBOOK_PROXY_AUTH_E2E_KEY);
    if (!Utility.isNullOrEmpty(e2e)) {
        logWebLoginCompleted(e2e);
    }

    if (error == null && errorCode == null && errorMessage == null) {
        try {
            AccessToken token = createAccessTokenFromWebBundle(request.getPermissions(),
                    extras, AccessTokenSource.FACEBOOK_APPLICATION_WEB,
                    request.getApplicationId());
            return LoginClient.Result.createTokenResult(request, token);
        } catch (FacebookException ex) {
            return LoginClient.Result.createErrorResult(request, null, ex.getMessage());
        }
    } else if (ServerProtocol.errorsProxyAuthDisabled.contains(error)) {
        return null;
    } else if (ServerProtocol.errorsUserCanceled.contains(error)) {
        return LoginClient.Result.createCancelResult(request, null);
    } else {
        return LoginClient.Result.createErrorResult(request, error, errorMessage, errorCode);
    }
}
 
Example #28
Source File: Request.java    From FacebookNewsfeedSample-Android with Apache License 2.0 5 votes vote down vote up
final String getUrlForBatchedRequest() {
    if (overriddenURL != null) {
        throw new FacebookException("Can't override URL for a batch request");
    }

    String baseUrl;
    if (this.restMethod != null) {
        baseUrl = ServerProtocol.BATCHED_REST_METHOD_URL_BASE + this.restMethod;
    } else {
        baseUrl = this.graphPath;
    }

    addCommonParameters();
    return appendParametersToBaseUrl(baseUrl);
}
 
Example #29
Source File: WebDialog.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
/**
 * Constructs a WebDialog using the parameters provided. The dialog is not shown,
 * but is ready to be shown by calling Dialog.show().
 *
 * @return the WebDialog
 */
public WebDialog build() {
    if (session != null && session.isOpened()) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_APP_ID, session.getApplicationId());
        parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, session.getAccessToken());
    } else {
        parameters.putString(ServerProtocol.DIALOG_PARAM_APP_ID, applicationId);
    }

    return new WebDialog(context, action, parameters, theme, listener);
}
 
Example #30
Source File: AuthorizationClient.java    From KlyphMessenger with MIT License 5 votes vote down vote up
@Override
boolean tryAuthorize(AuthorizationRequest request) {
    applicationId = request.getApplicationId();

    String e2e = getE2E();
    Intent intent = NativeProtocol.createProxyAuthIntent(context, request.getApplicationId(),
            request.getPermissions(), e2e);

    addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    return tryIntent(intent, request.getRequestCode());
}