简体   繁体   English

Azure移动应用程序身份验证

[英]Azure Mobile app authentication

I am using Azure App Service and I want to use Microsoft account to authenticate my users but after the user enter his credential and get "You have successfully logged in to website",the dialog does not close and does not returns control to my UWP. 我正在使用Azure App Service,并且我想使用Microsoft帐户对我的用户进行身份验证,但是在用户输入其凭据并获得“您已成功登录网站”后,该对话框不会关闭并且不会将控制权返回给我的UWP。

here is my code : 这是我的代码:

  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);

}

if I remove the "true" from LoginAsync I got an exception says : invalid format of the authentication response. 如果我从LoginAsync中删除“ true”,则会收到异常消息:身份验证响应的格式无效。

I think you want to use Microsoft Account with the Live SDK for sign-in, if so, then user = await App.MobileService.LoginAsync(provider, true); 我认为您想通过Live SDK使用Microsoft帐户登录,如果是这样,则user = await App.MobileService.LoginAsync(provider, true); is not right here. 在这里不正确。

In this scenario, we need to use the returned token to sign-in to your Mobile App backend: 在这种情况下,我们需要使用返回的令牌登录到您的Mobile App后端:

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

The user = await App.MobileService.LoginAsync(provider); user = await App.MobileService.LoginAsync(provider); method is for authentication withe the Active Directory Authentication Library, they are different. 方法是用于与Active Directory身份验证库进行身份验证的,它们是不同的。

You can refer to Client-managed authentication . 您可以参考客户端管理的身份验证

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM