Azure移动应用程序身份验证

本文关键字:身份验证 应用程序 移动 Azure | 更新日期: 2023-09-27 17:57:59

我正在使用Azure应用程序服务,我想使用Microsoft帐户对我的用户进行身份验证,但在用户输入凭据并获得"您已成功登录网站"后,对话框不会关闭,也不会将控制权返回给我的UWP。

这是我的代码:

  LiveLoginResult result = await liveIdClient.LoginAsync(new[] "wl.basic" });
 if (result.Status == LiveConnectSessionStatus.Connected)
 {
session = result.Session;
var client = new LiveConnectClient(result.Session);
LiveOperationResult meResult = await client.GetAsync("me");
var provider = MobileServiceAuthenticationProvider.MicrosoftAccount;
user = await App.MobileService.LoginAsync(provider, true);
}

如果我从LoginAsync中删除"true",我会得到一个异常:身份验证响应的格式无效。

Azure移动应用程序身份验证

我认为您想将Microsoft帐户与Live SDK一起用于登录,如果是这样,那么user = await App.MobileService.LoginAsync(provider, true);就不在这里。

在这种情况下,我们需要使用返回的令牌登录到您的移动应用程序后端:

MobileServiceUser loginResult = await App.MobileService
                .LoginWithMicrosoftAccountAsync(result.Session.AuthenticationToken);

user = await App.MobileService.LoginAsync(provider);方法用于使用Active Directory身份验证库进行身份验证,它们不同。

您可以参考客户端管理的身份验证。