I am using parse.com's Android API and have added Facebook/Twitter login support. This is working fine.
The tricky part appears to be logging out.
If I log in to my app using Twitter:
ParseTwitterUtils.logIn(UserLoginActivity.this, twitterLoginCallback);
Or using Facebook:
ParseFacebookUtils.logInWithReadPermissionsInBackground(UserLoginActivity.this, null, facebookLoginCallback);
I am prompted in a web dialog to enter my twitter credentials and then allow or deny access to my app. Once I allow it, I am able to log in successfulyl and I have access to my screen name. All is well!
When I try to log out of my ParseUser, I do get logged out. However, if I click either the Facebook or Twitter login button again, I am pre-authenticated as my previous account, I can't switch accounts.
I have tried:
- Checking Chrome and Browser and neither are logged in to Twitter.
- Logging out of the native Twitter/Facebook app
My login logic started as simply:
ParseUser.logOut();
For Twitter I have tried
- Uninstalling my application - This does fix it but is not an ideal solution.
- Not calling
Parse.enableLocalDatastore(this);
in myApplication
as suggested here: https://stackoverflow.com/a/26338326/494356 - Unlinking the Twitter account as suggested here: https://stackoverflow.com/a/34052718/494356. This also has the bad side effect of creating a new ParseUser each time (but still for the same Twitter account)
- I have tried changing permissions from 'Read Only` to 'Read and Write' as suggested here https://stackoverflow.com/a/27714159/494356. (Why this would matter doesn't really make sense to me anyway)
- I have tried setting the AuthToken to
null
ParseTwitterUtils.getTwitter().setAuthToken(null);
ParseTwitterUtils.getTwitter().setAuthTokenSecret(null);
For Facebook I have tried
- Uninstalling my application - This does not solve the problem.
Using the Facebook SDK Logout Features:
AccessToken.setCurrentAccessToken(null);
Profile.setCurrentProfile(null);
LoginManager.getInstance().logOut();
There used to be a
Session.closeAndClearTokenInformation()
as suggested here. But Facebook has Deprecated the Session class and it is no longer in the SDK.- Unlinking the Facebook account as suggested here. Again this causes duplicate ParseUsers and I am still able to log in using the saved credentials.
I would really appreciate any answers or suggestions. Even if you can only answer for either Twitter or Facebook but not both I would still love to hear it.