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:
My login logic started as simply:
ParseUser.logOut();
Parse.enableLocalDatastore(this);
in my Application
as suggested here: https://stackoverflow.com/a/26338326/494356
null
ParseTwitterUtils.getTwitter().setAuthToken(null);
ParseTwitterUtils.getTwitter().setAuthTokenSecret(null);
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.
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.
Click on the account switcher icon at the top. In case you haven’t added any additional Facebook account, click on Add account. Enter your login details. Later, when you need to switch accounts, tap on the account listed under the account switcher icon. Tip: To remove an account, click on the small cross icon on the account name.
If you want to sign out of the account you’re currently viewing, click the “Log Out” button. If you want to remove every account, select the “Manage Accounts” button. Finally, click the “Log Out Of All Accounts” to sign out of every Twitter profile authenticated on your computer.
Switch between Twitter Accounts Now that you have signed in to multiple Twitter accounts, you can easily switch between them. Start by heading to Twitter’s website using your computer and checking that you’re signed in to your primary account. Next, click on your profile in the bottom-left corner.
It’s a great and fastest way to log out and log in to more than one Facebook or Messenger account. When you switch accounts, you will receive notifications only for the account in which you are logged in. The account switcher feature is available only on facebook.com desktop version. The feature isn’t available on Facebook mobile apps.
In our App the login/logout process works fine for Facebook, E-Mail and even an own build google login. I can tell you the differences I see on the first look and maybe one of it does the trick for you.
First of all we do not work with the ParseUser
instance directly in our code, but have a MyUser
class that extends ParseUser
.
Second of all the login logic is encapsulated in a background service and not called directly in our Activity. That probably won't fix the problem. But in the background service we also cache the MyUser
instance, retrieve it if we need it and use that instance to logout the user (MyUser.logOut()
). And it is set to null
after the logout.
Last but not least: are you running the latest versions of the Parse SDK?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With