Last active
August 29, 2015 14:18
-
-
Save ricalo/d65837b9f83c2396b2ac to your computer and use it in GitHub Desktop.
Function to remove the entries in the ADAL token cache, delete the cookies and set the relevant objects to null.This allows the app to disconnect from Office 365 and then connect with a different user.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void disconnect(){ | |
//Clear tokens. | |
AuthenticationManager | |
.getInstance() | |
.getAuthenticationContext() | |
.getCache() | |
.removeAll(); | |
//Set manager objects to null. | |
MailManager.resetInstance(); | |
DiscoveryManager.resetInstance(); | |
AuthenticationManager.resetInstance(); | |
//Clear cookies. | |
if(Build.VERSION.SDK_INT >= 21){ | |
CookieManager.getInstance().removeSessionCookies(null); | |
CookieManager.getInstance().flush(); | |
} else { | |
CookieManager.getInstance().removeSessionCookie(); | |
CookieSyncManager.createInstance(this); | |
CookieSyncManager.getInstance().sync(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment