【发布时间】:2014-04-03 09:03:32
【问题描述】:
我从 Azure 移动服务开始,除了 Google 之外,所有提供商的身份验证都非常有效。
我为网络应用创建了客户端 ID: https://db.tt/s43Gi7ie
然后在 Windows Azure Mobile Service 面板上进行配置: https://db.tt/ri3VzYFD
然后我创建了新的 Windows Phone 8 应用,添加了 Azure 移动服务 nuget 包并编写了几行代码:
private MobileServiceUser _googleUser;
private async System.Threading.Tasks.Task AuthenticateGoogle()
{
while (_googleUser == null)
{
string message;
try
{
_googleUser = await App.MobileService.LoginAsync(MobileServiceAuthenticationProvider.Google);
message = string.Format("You are now logged in - {0}", _googleUser.UserId);
}
catch (InvalidOperationException e)
{
message = "You must log in. Login Required";
}
MessageBox.Show(message);
}
}
但每次我调用 AuthenticateGoogle 方法时都会收到 400 错误。
System.InvalidOperationException: Authentication failed with HTTP response code 400.
at Microsoft.WindowsAzure.MobileServices.AuthenticationBroker.<AuthenticateAsync>b__0()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.WindowsAzure.MobileServices.MobileServiceAuthentication.<LoginAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at PhoneApp1.SSOPage.<AuthenticateGoogle>d__19.MoveNext()
我做错了什么?
【问题讨论】:
-
我可以读到它是为 Web 应用程序创建的。如果我错了,请告诉我。此外,我在本指南中找到了说明:chrisrisner.com/…
-
对不起,我没有得到你。在我的问题中,图像db.tt/s43Gi7ie 直接取自谷歌开发控制台“Web 应用程序的客户端 ID”。能不能说的清楚一点?
标签: azure windows-phone-8 google-oauth azure-mobile-services google-authentication