Reputation: 2275
I am using Microsoft Azure Active Directory SDK for Authentication in my Android App. SignIn & Graph API implementation is working fine. But when I am calling the signout method of SDK. It signout me from the app. But when I pressed again login, it opens the browser overlay for SignIn. There Microsoft page shows me my last account as an item to pick. Once I clicked on the item it allows me to log in the app without asking password again.
So it seems Microsoft does not clean the User account instance in the browser which opens by SDK. I tried to clean Cookies & Cache in the signout callback method. but No success yet.
Has anybody faced such a problem before? Some days before I faced such a problem with the OKta Authentication also. It was also an open browser overlay for login.
Upvotes: 1
Views: 872
Reputation: 326
It's worked for me,
Clear your cookies and shared preferences also Clear browser cookies after logout
private fun logoutFromMS(){
// Clear Microsoft pref
requireActivity()
.applicationContext
.getSharedPreferences("com.microsoft.aad.adal.cache", 0)
.edit()
.clear()
.apply()
requireActivity()
.applicationContext
.getSharedPreferences("WebViewChromiumPrefs", 0)
.edit()
.clear()
.apply()
val cookieManager: CookieManager =
CookieManager.getInstance()
cookieManager.removeAllCookies { data ->
Timber.d("DATA:removeAllCookies: $data")
}
cookieManager.removeSessionCookies { data ->
Timber.d("DATA:removeSessionCookies: $data")
}
cookieManager.flush()
}
Upvotes: 1
Reputation: 2766
Here is a thread discussing something similar. And is likely what you are running into. https://github.com/Azure-Samples/active-directory-xamarin-native-v2/issues/86 Mainly that you can clear the token cache for the embedded browser, but not from the chrome browser. and that is sort of by design.
basically you are logging out of your app, Not out of azure ad. if there are other apps or sites or email accounts using that same login, then you will kick them all out which is not necessarily a good thing. In the thread there is a mention of something similar but with google signin: How to Logout of an Application Where I Used OAuth2 To Login With Google? this gives you some quick and dirty example of how to log off of the authprovider, basically calling the logout endpoint. you would have to do something similar if you wanted to do it for azure.
Upvotes: 0