Xamarin 如何在UWP中使用WebAccountManager使用窗口凭据对应用程序进行身份验证
我正在尝试使用WebAccountManager,因为我的组织链接可以使用与Windows用户相同的帐户(在组织域上)登录。我无法从Windows 10 PC获取任何令牌或现有帐户 我还使用Xamarin 如何在UWP中使用WebAccountManager使用窗口凭据对应用程序进行身份验证,xamarin,active-directory,win-universal-app,uwp,windows-authentication,Xamarin,Active Directory,Win Universal App,Uwp,Windows Authentication,我正在尝试使用WebAccountManager,因为我的组织链接可以使用与Windows用户相同的帐户(在组织域上)登录。我无法从Windows 10 PC获取任何令牌或现有帐户 我还使用WebAccountProvider尝试了AccountsSettingsPane,如下所示: AccountsSettingsPane.GetForCurrentView().AccountCommandsRequested += OnlineDataStore_AccountCommandsRequest
WebAccountProvider
尝试了AccountsSettingsPane
,如下所示:
AccountsSettingsPane.GetForCurrentView().AccountCommandsRequested += OnlineDataStore_AccountCommandsRequested;
AccountsSettingsPane.Show();
WebAccountProvider wap = await WebAuthenticationCoreManager.FindAccountProviderAsync("https://si.business360online.com/");
but wap is always null.
然后,OnlineDataStore\u accountcommands请求的如下所示:
AccountsSettingsPane.GetForCurrentView().AccountCommandsRequested += OnlineDataStore_AccountCommandsRequested;
AccountsSettingsPane.Show();
WebAccountProvider wap = await WebAuthenticationCoreManager.FindAccountProviderAsync("https://si.business360online.com/");
but wap is always null.
有人能帮助我们如何通过UWP中当前登录用户的Windows凭据登录吗?使用以下更多的研发,我可以作为Windows当前用户登录,但在Windows.Web.Http中,我无法控制注销/清除凭据等
编辑1:以下代码片段可以工作,但System.Net.Http
可能在将来的版本中被弃用
var handler = new HttpClientHandler();
handler.AllowAutoRedirect = true;
handler.Credentials = CredentialCache.DefaultCredentials;
var httpClient = new System.Net.Http.HttpClient(handler);
System.Net.Http.message = await httpClient.GetAsync(feedUrl);
编辑2:这可能对某人有帮助:要在UWP/Windows Mobile中启用Windows身份验证,必须启用。我发现了以下几点:
- 对于
System.Net.Http
我们可以通过设置CredentialCache.DefaultCredentials
- 对于
Windows.Web.Http
,如果在HttpProtocolFilter
中未设置凭据,它将自动以Windows凭据登录
要在UWP/Windows Mobile中启用Windows身份验证,必须启用。(上述内容已被编辑)
- 对于
System.Net.Http
我们可以通过设置CredentialCache.DefaultCredentials
- 对于
Windows.Web.Http
,如果在HttpProtocolFilter
中未设置凭据,它将自动以Windows凭据登录
要在UWP/Windows Mobile中启用Windows身份验证,必须启用。(上述内容已被编辑)
- 对于
System.Net.Http
我们可以通过设置CredentialCache.DefaultCredentials
- 对于
Windows.Web.Http
,如果在HttpProtocolFilter
中未设置凭据,它将自动以Windows凭据登录
因此,即使System.Net.Http在将来也可能会被弃用,替代的Microsoft.Net.Http对您有效吗?看起来您需要为域windows用户获取信息,有一个UWP代码示例项目可以这样做。@Jackie,我没有深入研究示例,但WebAccountManager对我不起作用。对我有用的东西是用Edit 2
编写的。因此,即使System.Net.Http将来也可能会被弃用,替代的Microsoft.Net.Http对你有用吗?看起来你需要为域windows用户获取信息,有一个UWP代码示例项目可以做到这一点。@Jackie,我没有深入研究示例,但是WebAccountManager不为我工作。对我有用的内容写在edit2
中。