Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem displaying MSAL login page in Android Emulator using Xamarin.Forms for Android

I'm attempting to build and run the Android MSAL example provided by Microsoft here in VS2019. It builds and starts successfully, but after clicking on the sign in button it opens the browser and navigates the the login page but fails to display it correctly. The VS debug output displays:

W/UserDetailsClient.Droid(12360): type=1400 audit(0.0:224): avc: denied { link } for comm=54687265616420506F6F6C20576F72 name="PropertyStore.forms.tmp" dev="dm-1" ino=124432 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file permissive=0

I've seen a similar question posted here. Updating all the packages to the latest version hasn't resolved the issue.

I've also followed the steps here to ensure that Chrome is setup for the Android Emulator.

The android manifest looks like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto">
    <uses-sdk android:minSdkVersion="27" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
    <application>
        <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="msala7d8cef0-4145-49b2-a91d-95c54051fa3f" android:host="auth" />
            </intent-filter>
        </activity>
    </application>
</manifest>

Any help would be much appreciated!

like image 566
Cam Avatar asked Sep 02 '25 09:09

Cam


1 Answers

I've found the solution to my problem. Not being able to progress to the login screen was resolved by using the latest version of the sample.

As for confirming the sign-in and continuing back to the app, the optional step 3b in the sample is required for the android demo to work. Without the correct client ID, control is not passed back to the app. After updating the sample file MsalActivity.cs in the UserDetailsClient.Droid project with the included ClientID from App.cs in the UserDetailsClient project it worked.

I initially read this step as optional, and only required updating if you registered the sample as a new app as mentioned in the optional step 2.

This link also explains in better detail the options for updating the android manifest or creating the activity in code.

like image 148
Cam Avatar answered Sep 05 '25 01:09

Cam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!