MSAL 不 运行 WebView 登录

MSAL doesn't run WebView for login

我在 Xamarin.Forms 中使用 MSAL 对 B2C 中的用户进行身份验证。 MSAL 4.0.0 版本和 Xamarin.Forms 3.2.0.871581。我注意到我的 MSAL 没有 运行 登录用户的 WebView。我尝试了几种解决方案,但问题仍然存在:-( 如果有人有这样的问题? 提前致谢

使用您自己的 B2C 用户旅程价值来尝试这个B2C Xamarin sample which uses MSAL v4. You can swamp out the values in B2CConstants.cs,示例应该可以正常工作。

注意 Android,您需要使用 .WithParentActivityOrWindow(ParentActivityOrWindow) 设置 Activity,就像在示例中完成 here 一样,因此一旦交互完成,令牌就会取回发生了。 基本上是这样的:

var authResult = AcquireTokenInteractive(scopes)
 .WithParentActivityOrWindow(parentActivity)
 .ExecuteAsync();

此外,在 Android 上,您需要覆盖 ActivityOnActivityResult 方法,如 here in the sample

所示
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
     base.OnActivityResult(requestCode, resultCode, data);
     AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);
}