8

I know how to login:

ParseTwitterUtils.logIn(loginView.getCurrentContext(), new LogInCallback() {
    @Override
    public void done(ParseUser parseUser, ParseException e) {
        if (e == null) {
            String welcomeMessage = "";
            if (parseUser.isNew()) {
                welcomeMessage = "Hello new guy!";
            } else {
                welcomeMessage = "Welcome back!";
            }
            loginView.showLoginSuccess(parseUser, welcomeMessage);
        } else {
            String errorMessage = "Seems we have a problem : " + e.getLocalizedMessage();
            loginView.showLoginFail(errorMessage);
        }
    }
});

And to logout :

ParseUser.logOutInBackground(new LogOutCallback() {
    @Override
    public void done(ParseException e) {
        if (e == null) {
            homeView.goLogin(true, "See you soon");
        } else {
            homeView.goLogin(false, "Error detected : " + e.getLocalizedMessage());
        }
    }
});

But when I want to log in again, I don't have the alert dialog asking me to choose accounts (i use the webview since Twitter app is not installed on the emulator).

How to truly logout from Parse using Twitter login?

Joe Mayo
  • 7,501
  • 7
  • 41
  • 60
Tsunaze
  • 3,204
  • 7
  • 44
  • 81

2 Answers2

1

In iOS, you can revise the source code of Parse in PFOauth1FlowDialog.m

- (void)loadURL:(NSURL *)url queryParameters:(NSDictionary *)parameters   {
    NSMutableDictionary *_parameter = [[NSMutableDictionary alloc] init];
    [_parameter setObject:@"true" forKey:@"force_login"];
    [_parameter addEntriesFromDictionary:parameters];
    _loadingURL = [[self class] _urlFromBaseURL:url queryParameters:_parameter];
    NSURLRequest *request = [NSURLRequest requestWithURL:_loadingURL];
    [_webView loadRequest:request];
}

Then everything should work fine, And this should also work in Android.

高玉璁
  • 21
  • 2
0

Use the unlink functions from ParseTwitterUtils: https://parse.com/docs/android/api/com/parse/ParseTwitterUtils.html#unlink(com.parse.ParseUser)

This will remove the link between the twitter account and the parse user.

The confusion seems to stem from the fact that the api is so straightforward.

What you're doing in the login is associating a twitter account with a parse user and logging in as that parse user. Then when you are logging out, you are only logging out of the parse user, and the twitter account is still linked to the parse user. Therefore when you go to log in again it automatically uses the twitter account to log in as the parse user.

craigts
  • 2,857
  • 1
  • 25
  • 25
  • I'm going to try it out later. But doesn't this mean that it will create another user again and again when you login with Twitter? – Tsunaze Dec 04 '15 at 09:00
  • Yes it would do that. I guess I don't know enough about your application to help then. Are you trying to make sure it just re-auths with Twitter every time? A possible solution then would be to use anonymous parse users via enableAutomaticUser() and then only treat the user as logged in if they are linked to a twitter account (using link to 'log in' and unlink to 'log out'). – craigts Dec 04 '15 at 09:18