C# 使用MicrosoftAccountAsync登录总是失败
我已经创建了一个通用应用程序和azure移动服务。我遵循了azure网站提供的关于添加microsoft帐户身份验证的教程。为此,我正在使用最新的Live SDK 客户端,我正在使用此代码,这或多或少与教程无关:C# 使用MicrosoftAccountAsync登录总是失败,c#,azure-mobile-services,live-sdk,C#,Azure Mobile Services,Live Sdk,我已经创建了一个通用应用程序和azure移动服务。我遵循了azure网站提供的关于添加microsoft帐户身份验证的教程。为此,我正在使用最新的Live SDK 客户端,我正在使用此代码,这或多或少与教程无关: const string ReferralUrl = "https://my-url-here.azure-mobile.net/"; static MobileServiceClient MobileService = new MobileServiceClient(
const string ReferralUrl = "https://my-url-here.azure-mobile.net/";
static MobileServiceClient MobileService = new MobileServiceClient(
"https://my-url-here.azure-mobile.net/",
"my key");
MobileServiceUser _user;
private LiveConnectSession _session;
private async Task Authenticate()
{
var authClient = new LiveAuthClient(ReferralUrl);
while (_session == null)
{
var result = await authClient.LoginAsync(new[] { "wl.basic" });
if (result.Status == LiveConnectSessionStatus.Connected)
{
_session = result.Session;
var client = new LiveConnectClient(result.Session);
var meResult = await client.GetAsync("me");
return;
}
else
{
break;
}
}
_session = null;
}
public async Task<bool> Login()
{
try
{
await Authenticate();
_user = await MobileService
.LoginWithMicrosoftAccountAsync(_session.AuthenticationToken);
}
catch (Exception ex)
{
//Debug.WriteLine(ex.Message);
//return false;
}
return true;
}
const string ReferralUrl=”https://my-url-here.azure-mobile.net/";
静态MobileServiceClient MobileService=新的MobileServiceClient(
"https://my-url-here.azure-mobile.net/",
“我的钥匙”);
移动服务用户;
专用LiveConnectSession(会话);;
专用异步任务身份验证()
{
var authClient=new LiveAuthClient(ReferralUrl);
while(_session==null)
{
var result=await authClient.LoginAsync(新[]{“wl.basic”});
if(result.Status==LiveConnectSessionStatus.Connected)
{
_会话=结果。会话;
var client=newliveconnectclient(result.Session);
var meResult=await client.GetAsync(“me”);
返回;
}
其他的
{
打破
}
}
_会话=空;
}
公共异步任务登录()
{
尝试
{
等待验证();
_用户=等待移动服务
.loginWithMicrosoftAccountSync(_session.AuthenticationToken);
}
捕获(例外情况除外)
{
//Debug.WriteLine(例如消息);
//返回false;
}
返回true;
}
以下事实已针对本申请进行了验证:
- 已创建存储条目
- 商店条目已与通用应用程序关联(这已针对win8.1和wp8.1项目执行)
- 商店应用程序具有以下设置:
- 移动或桌面:是
- jwt:是的
- 安全:已激活
- 重定向url:设置为
有什么想法吗?此功能-基于Microsoft帐户客户端SDK(live SDK)或Facebook的信息进行身份验证-目前移动服务的.NET后端不支持此功能。NET后端支持通过Microsoft/Facebook/Google/Twitter的web界面进行身份验证,或Azure Active Directory的客户端身份验证。对您想要的特性的支持应该在即将发布的版本中实现。您可以在实时查看上的公告