使用 Xamarin 和 Azure AD B2C 缺少自定义选项卡的回退

Fallback for missing custom tabs with Xamarin and Azure AD B2C

我在 Xamarin Authorization with Azure AD B2C

上关注了样本

使用自定义 Chrome 标签(和 Safari 等效项)。

如果移动设备上没有安装 Chrome,我找不到任何关于如何处理这种情况的资源。我刚刚在模拟器中注意到,它只是引发了一个必须安装 Chrome 的错误对话框。但我不想将使用替代浏览器的用户排除在签署 in/up 之外。

是否有任何 links/tutorials 涵盖此(关键)行为?

您将不得不使用不同的库,例如:

AppAuth for Android

"When a Custom Tabs implementation is provided by a browser on the device (for example by Chrome), Custom Tabs are used for authorization requests. Otherwise, the default browser is used as a fallback."

AppAuth for iOS

"iOS 9+ uses the in-app browser tab pattern (via SFSafariViewController), and falls back to the system browser (mobile Safari) on earlier versions."

(注意Microsoft Authentication Library与the IETF's Best Current Practice for OAuth 2.0 for Native Apps一致即:

"...当前最好的做法是在外部用户代理(通常是浏览器)中执行 OAuth 授权请求,而不是在嵌入式用户代理(例如使用 web 视图实现的用户代理)中执行。"

MSAL 现在支持使用 Android / iOS:

的嵌入式浏览器进行回退

https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/msal-net-2-released#you-can-now-leverage-the-embedded-web-browser-in-xamarinios-and-xamarinandroid

You can now leverage the embedded web browser in Xamarin.iOS and Xamarin.Android

In the previous versions of MSAL.NET, Xamarin.Android and Xamarin.iOS used the System web browser interacting with Chrome tabs. This was great if you wanted to benefit from SSO, but that was not working on some Android phones which device manufacturers did not provide Chrome, or if the end user had disabled Chrome. As an app developer, you can now leverage an embedded browser. To support this, the UIParent class now has a constructor taking a Boolean to specify if you want to choose the embedded browser. It also has a static method, IsSystemWebviewAvailable(), to help you decide if you want to use it. For instance, on Android: bool useSystemBrowser = UIParent.IsSystemWebviewAvailable(); App.UIParent = new UIParent(Xamarin.Forms.Forms.Context as Activity, !useSystemBrowser);

For more details about this possibility see the article in MSAL's conceptual documentation: https://aka.ms/msal-net-uses-web-browser. Also the web view implementation might change in the future