Azure Only(XamarinForms.Android)中的设备方向上,Azure AD(ADAL)登录屏幕丢失了输入的用户电子邮件 [英] Azure AD (ADAL) Login Screen Loses Entered User Email on Device Orientation in Android Only-XamarinForms.Android

查看:82
本文介绍了Azure Only(XamarinForms.Android)中的设备方向上,Azure AD(ADAL)登录屏幕丢失了输入的用户电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Xamarin.Forms应用程序,该应用程序使用ADAL( Microsoft.IdentityModel.Clients.ActiveDirectory )针对Azure AAD对用户进行身份验证。一切正常,但在Android上,设备方向会在Microsoft身份验证屏幕上松开用户电子邮件。

I have Xamarin.Forms application that authenticates user against Azure AAD using ADAL (Microsoft.IdentityModel.Clients.ActiveDirectory). That all works fine but on Android, device orientation looses user email on the Microsoft authentication screen.

在这里,我处于人像模式,并且输入了用户电子邮件:

Here I am in Portrait mode and I have entered user email:

单击下一步进入屏幕,要求输入密码。如果我现在在Android上旋转设备,它将使我返回到上面的黑屏,我在上面输入的用户电子邮件将丢失:

Clicking on Next lands on screen asking to enter password. If I now rotate device on Android, it will return me back to blank screen above, user email I entered above is lost:

设备旋转不应使用户返回并再次提示用户输入电子邮件。它应该停留在密码提示符下。

如何防止轮换提示用户输入电子邮件?我不想禁用旋转,我只是想防止它返回到再次提示用户电子邮件的屏幕。

这是Xamarin.Forms应用程序,并且我的MainActivity已经具有 ConfigChages.Orientation 属性,如下所示;但是,这不能解决问题:

This is Xamarin.Forms application and my MainActivity has already ConfigChages.Orientation attribute like below; however, this is not solving the issue:

[Activity(Name = "my.mainactivity"
, Label = "MyApp"
, Icon = "@drawable/icon"
, ConfigurationChanges = ConfigChanges.ScreenSize 
    | ConfigChanges.SmallestScreenSize 
    | ConfigChanges.ScreenLayout 
    | ConfigChanges.Orientation)]
public class MainActivity : Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
   ...
}

更新

即使我在调用AcquireTokenAsync和在调用收到响应后将其解冻,它的行为仍然相同-即使我将其父项(MainActivity)冻结为Portrait(这是在PlatformParameters中传递给AcquireTokenAsync调用的所有者),它仍将旋转Microsoft登录页面。活动保持纵向状态,但登录页面仍会旋转并丢失数据。

Even if I freeze orientation to Portrait before call to AcquireTokenAsync and unfreeze it after the call receives response, it still behaves same - it will still rotate the Microsoft sign in page even though I freeze its parent (MainActivity) to Portrait (which is the owner passed in PlatformParameters to the call to AcquireTokenAsync. So, my activity stays in portrait but that sign-in page still rotates and looses data. It appears that the WebView Microsoft uses internally in AcquireTokenAsync is not following orientation settings on the activity passed inside PlatformParameters to AcquireTokenAsync.

Microsoft确认这是他们的内部问题。在AcquireTokenAsync中,ly并未遵循在PlatformParameters内​​部传递给AcquireTokenAsync的活动的方向设置。如果您还在Android设备上遇到此问题,在该问题上设备旋转会返回提示用户输入电子邮件,则可以在此处跟踪ADAL和MSAL的修复进度:

Confirmed by Microsoft that this is their internal issues. If you are also running into this issue on Android where device rotation returns you back to prompt for user email, you can follow up progress of fixes for both ADAL and MSAL here:

https://github.com/AzureAD/azure-activedirectory -library-for-dotnet / issues / 1622 https:// github。 com / xamarin / xamarin-android / issues / 3326

推荐答案

此问题是由Microsoft的ADAL组件<$引起的c $ c> Microsoft.IdentityModel.Clients.ActiveDirectory ,该问题已在几周前发布的5.1.0版本中修复(当前版本为5.2.0)。

This issue is caused by Microsoft's ADAL component Microsoft.IdentityModel.Clients.ActiveDirectory and it has been fixed in 5.1.0 version released just couple of weeks ago (current version is 5.2.0).

要解决此问题,我要做的是:
1.将ADAL从3.19.8更新到5.2.0(低于5.1.0的所有版本都有此问题)
2.然后将修改后的AuthorityURL传递给AuthenticationContext c-tor,例如 https://login.microsoftonline.com/my-tenant-id/oauth2/authorize https://即使Microsoft在大多数地方都声称更改不是非必需的,login.microsoftonline.com / my-tenant-id

What I had to do in order to fix this issue is: 1. Update ADAL from 3.19.8 to 5.2.0 (everything below 5.1.0 has this problem) 2. Then modified AuthorityURL passed to AuthenticationContext c-tor from something like https://login.microsoftonline.com/my-tenant-id/oauth2/authorize to https://login.microsoftonline.com/my-tenant-id

数字2是必需的

此后,我能够像以前一样进行身份验证,但是在提供用户ID和/或密码。

After this, I was able to authenticate just like before but rotation on Android would not loose already provided user id and/or password.

这篇关于Azure Only(XamarinForms.Android)中的设备方向上,Azure AD(ADAL)登录屏幕丢失了输入的用户电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆