0

I have used the following tutorial to integrate sign in for azure adb2c in my android app using appauth Android appauth.

The tutorial no where mentions how to sign out of the app.

Nothing is mentioned in the azure documentation regarding this as well.

Any idea how this can be done?

Dharman
  • 30,962
  • 25
  • 85
  • 135
A.S
  • 798
  • 1
  • 10
  • 32

2 Answers2

1

You can call your MobileServiceClient.LogoutAsync();

Then you have to clear the cookies in the browser for the login. Depending on the app installed on the device, it could be Web View or Chrome custom tab.

If it's a WebView, you can clean the cookies of your OAuth2.0 by calling:

CookieManager.Instance.RemoveAllCookies(null);
CookieManager.Instance.Flush();

If the Oauth2.0 login is using Chrome custom tab, then you can invoke logout url for your oauth using the browser custom tab. (Sample answer from: https://github.com/Azure/azure-mobile-apps-ios-client/issues/51#issuecomment-393294895)

var logoutUrl = "https://login.windows.net/common/oauth2/logout";
var uri = Android.Net.Uri.Parse(logoutUrl);

var builder = new CustomTabsIntent.Builder();
var customTabsIntent = builder.Build();
customTabsIntent.LaunchUrl(MainActivity, uri);

But this will not automatically close the browser after logout... I am yet to figure out how to do this?

Felix
  • 336
  • 2
  • 6
-1

Azure Mobile Android SDK provide the method to help us logout, we can use MobileServiceClient.logout() to achieve this.

Here is the original code for your reference:

/**
 * Log the user out of the Mobile Service
 */
public ListenableFuture logout() {
    final SettableFuture logoutFuture = SettableFuture.create();

    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            mCurrentUser = null;
            logoutFuture.set(null);
            return null;
        }
    }.execute();
    return logoutFuture;
}

Screenshot of the SDK in Android Studio: enter image description here

This thread in MSDN may be helpful to you:

Cant logout MobileServiceUser from app

Lee Liu
  • 1,981
  • 1
  • 12
  • 13