【问题标题】:Azure B2C in .NET MAUI.NET MAUI 中的 Azure B2C
【发布时间】:2022-12-23 03:53:09
【问题描述】:

    <application android:label="ADB2CAuthorization">
        <activity android:name="microsoft.identity.client.BrowserTabActivity"
                android:exported="true">
            <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="msal59206468-8451-4503-b081-79b09b295d1a" android:host="auth" />
            </intent-filter>
        </activity>
    </application>

将上面粘贴的代码添加到 AndroidManifest.xml 文件会导致应用程序产生以下错误。

Error XA0134: The application does not have the 'android:debuggable' attribute set in the AndroidManifest.xml.
This is required in order for Fast Deployment to work. This is normally enabled by default by 
the Xamarin.Android build system for Debug builds. Please check that you to not have this attribute
set on the 'application' element in your 'AndroidManifest.xml'.
If you have a class that derives from 'Android.App.Application' and are using the '[Application]' make sure the 
'Debuggable' property is not set at all as it will override the value for debug builds.         0   

添加 debuggable 属性会使应用程序无法部署。

任何成功地将 MSAL 集成到他/她的 Android MAUI 应用程序中的人请帮忙

【问题讨论】:

    标签: android xamarin xamarin.forms msal maui


    【解决方案1】:

    AndroidManifest.xml

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android">
        <application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true">
            <activity android:name="microsoft.identity.client.BrowserTabActivity" android:configChanges="orientation|screenSize" android:exported="true">
                <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="msal59206468-8451-4503-b081-79b09b295d1a" android:host="auth" />
                </intent-filter>
            </activity>
            <activity android:name="MauiAppBasic.Platforms.Android.Resources.MsalActivity" android:configChanges="orientation|screenSize" android:exported="true">
                <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="msal59206468-8451-4503-b081-79b09b295d1a" android:host="auth" />
                </intent-filter>
            </activity>
        </application>
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.INTERNET" />
    </manifest>
    

    然后在Android项目里面创建一个C#类MsalActivity.cs

    using Android.App;
    using Android.Content;
    using Microsoft.Identity.Client;
    
    namespace MedbaseApplication.Platforms.Android
    {
        [Activity(Exported = true)]
        [IntentFilter(new[] { Intent.ActionView },
            Categories = new[] { Intent.CategoryBrowsable, Intent.CategoryDefault },
            DataHost = "auth",
            DataScheme = "msalxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx")]
        public class MsalActivity : BrowserTabActivity
        {
        }
    }
    

    如需更多信息,请点击链接https://devblogs.microsoft.com/dotnet/authentication-in-dotnet-maui-apps-msal/ 这个 Xamarin 指南也可能有帮助 https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-net-xamarin-android-considerations

    【讨论】:

      猜你喜欢
      • 2023-01-31
      • 1970-01-01
      • 1970-01-01
      • 2022-12-24
      • 1970-01-01
      • 2020-10-25
      • 2019-05-30
      • 2022-12-27
      • 2023-01-12
      相关资源
      最近更新 更多