Git Product home page Git Product logo

Comments (10)

grantland avatar grantland commented on May 19, 2024

This is working as intended. What you're seeing is that the user currently has Facebook auth data attached to it, but is currently in a dirty state as the request has failed.

You should update your callback as the request has only succeeded if e != null.

from parse-sdk-android.

kenilt avatar kenilt commented on May 19, 2024

When I check this function again ParseFacebookUtils.isLinked(user) in somewhere, it's return true, but currentUser not linked to any Facebook account, and currentUser don't have authData on parse.com

from parse-sdk-android.

grantland avatar grantland commented on May 19, 2024

The information isn't persisted on the server as your request failed, however, the ParseUser you have locally has the authData attached since it attempted to link to a Facebook account, but failed. Since it has it locally, ParseFacebookUtils.isLinked(user) will return true.

from parse-sdk-android.

parse-github-bot avatar parse-github-bot commented on May 19, 2024

Thank you for your feedback. We use the issues tracker here to track valid bugs in our SDK. Your question seems to be more about how to use Parse. Could you check out the following resources?

from parse-sdk-android.

parse-github-bot avatar parse-github-bot commented on May 19, 2024

This issue has not been updated for 7 days. If you have additional information to help pinpoint this issue as an SDK bug, please comment on this issue. We will close this issue in 7 days if no additional information is provided. Thank you for your feedback.

from parse-sdk-android.

parse-github-bot avatar parse-github-bot commented on May 19, 2024

We are closing this issue due to another 7 days of inactivity. If you have additional information to help pinpoint this issue as an SDK bug, please reopen it with the additional information.Thank you for your feedback.

from parse-sdk-android.

SobanMahmood avatar SobanMahmood commented on May 19, 2024

This behavior of ParseFacebookUtils library does not seem to be correct. Because this may produce inconsistencies in some cases as on server user is saved as Anonymous user whereas on device it is non-Anonymous user. So I think ParseFacebookUtils.isLinked(user) should return false after failed linking.
Also although I am an Android developer but I think on iOS platform, if this 208 error occurs, iOS version of this library does not start returning true for ParseFacebookUtils.isLinked(user) instead it returns false. This iOS sdk behavior seems consistent with the server state and I think same should be in Android.

For solutions, I tried to use persistent storage for tracking if user is actually not linked, which was overkill. Then I have managed to retain correct state by calling ParseFacebookUtils.unlink(user) for current user in case 208 error had occurred. I am not sure if this workaround is correct, but it seems to be working.

By the way even if this buggy behavior seems fine this should be mentioned in docs and sample codes.

It has possible workarounds, but I still think that library behavior needs to be changed.

from parse-sdk-android.

SobanMahmood avatar SobanMahmood commented on May 19, 2024

@grantland could you please help a little here.
Could this issue be reopened as suggested in my last comment, or should I create new issue for it, or is it not worth it?

from parse-sdk-android.

kenilt avatar kenilt commented on May 19, 2024

@SobanMahmood I tried to find some solution for this problem, Finally I called unlikFacebook account if I got error code 208 in response, I wrote some code like below:

List<String> permissions = Arrays.asList("public_profile", "email", "user_birthday");
ParseFacebookUtils.linkWithReadPermissionsInBackground(currentUser, getActivity(), permissions, new SaveCallback() {
    @Override
    public void done(ParseException e) {
        if (e != null) {
            // has error
            if (e.getCode() == 208) {
                ParseFacebookUtils.unlinkInBackground(ParseUser.getCurrentUser());
                MaterialDialogUtils.showOopsMaterialDialogs(getActivity(), "Another user is already linked to this facebook ID. Please try another FB account.");
            } else {
                MaterialDialogUtils.showOopsMaterialDialogs(getActivity(), "Can't link your account to FB. Code = " + e.getCode());
            }
        } else if (LoginHelper.isLinkedWithFacebook()) {
            // linked success
        }
    }
});

Hope it will help some one have same problem. :)

from parse-sdk-android.

SobanMahmood avatar SobanMahmood commented on May 19, 2024

Thank you @kenilt . That seems to be working. I am using the similar solution. For more consistency with future version changes, I have also included ParseFacebookUtils.isLinked(user) condition before calling unlink in case of error 208 like this.

            ...
            if (e.getCode() == 208) {
                if (ParseFacebookUtils.isLinked(ParseUser.getCurrentUser())) {
                    ParseFacebookUtils.unlinkInBackground(ParseUser.getCurrentUser());
                }
                MaterialDialogUtils.showOopsMaterialDialogs(getActivity(), "Another user is already linked to this facebook ID. Please try another FB account.");
            } else {
                MaterialDialogUtils.showOopsMaterialDialogs(getActivity(), "Can't link your account to FB. Code = " + e.getCode());
            }
            ...

from parse-sdk-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.