Skip to content

Android system browser

jennyf19 edited this page May 12, 2020 · 21 revisions

Update the Android manifest

If you're using the system browser (on by default in MSAL .NET) and the redirection back to your application after sign-in is not occurring, it may be because the android manifest is not configured correctly. Make sure you have these settings in the android manifest, especially note the android:scheme and android:host values:

The AndroidManifest.xml should contain the following values:

<activity android:name="microsoft.identity.client.BrowserTabActivity">
	<intent-filter>
		<action android:name="android.intent.action.VIEW" />
		<category android:name="android.intent.category.DEFAULT" />
		<category android:name="android.intent.category.BROWSABLE" />
		<data android:scheme="msal{client_id}" android:host="auth" />
         </intent-filter>
</activity>

Custom Tabs

Starting with MSAL.NET 2.4.0-preview, MSAL.NET supports browsers other than Chrome and no longer requires Chrome be installed on the Android device for authentication.

It is recommended to use browsers which support custom tabs, such as the following browsers:

Browsers with custom tabs support Package Name
Chrome com.android.chrome
Microsoft Edge com.microsoft.emmx
Firefox org.mozilla.firefox
Ecosia com.ecosia.android
Kiwi com.kiwibrowser.browser
Brave com.brave.browser

In addition to browsers with custom tabs support, based on our testing, a few browsers that do not support custom tabs will also work for authentication, such as Opera, Opera Mini, InBrowser, and Maxthon. See table for test results.

Known Issues

  • If the user has no browser enabled on the device, MSAL.NET will throw an AndroidActivityNotFound Exception.

    • Mitigation: You need to inform the user that they should enable a browser (preferably one with custom tabs support) on their device.
  • If authentication fails (ex. authentication launches with DuckDuckGo), MSAL.NET will return an AuthenticationCanceled MsalClientException.

    • Root Problem: A browser with custom tabs support was not enabled on the device. Authentication launched with an alternate browser, which was not able to complete authentication.
    • Mitigation: You need to inform the user that they should install a browser (preferably one with custom tab support) on their device.

Devices and browsers tested

Browser* Result
Huawei/One+ Chrome* Pass
Huawei/One+ Edge* Pass
Huawei/One+ Firefox* Pass
Huawei/One+ Brave* Pass
One+ Ecosia* Pass
One+ Kiwi* Pass
Huawei/One+ Opera Pass
Huawei OperaMini Pass
Huawei/One+ InBrowser Pass
One+ Maxthon Pass
Huawei/One+ DuckDuckGo User cancelled auth
Huawei/One+ UC Browser User cancelled auth
One+ Dolphin User cancelled auth
One+ CM browser User cancelled auth
Huawei/One+ none installed AndroidActivityNotFound ex

Supports Custom Tabs*

Getting started

See this guide with code snippets and additional information on using system browser with Xamarin Android.

Getting started with MSAL.NET

Acquiring tokens

Web Apps / Web APIs / daemon apps

Desktop/Mobile apps

Advanced topics

FAQ

Other resources

Clone this wiki locally