【问题标题】:Authentication with Windows Azure Mobile Services agains Google OAuth failed - 400 error使用 Windows Azure 移动服务再次验证 Google OAuth 失败 - 400 错误
【发布时间】: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


【解决方案1】:

我觉得不错。我做了与您遵循的教程基本相同的步骤。我在使用 Google 时遇到了问题,所以我只是去了 Google Developers Console,创建了一个新的客户端 ID,然后用旧的密钥替换了新的密钥。我还包含了相同的 URL,但作为 http:// 而不是 https://,但在我看到它再次开始工作后,我把 http:// 去掉,它仍然有效。

除此之外,请确保所有内容都拼写正确并祝你好运。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-30
    • 1970-01-01
    • 2012-05-31
    相关资源
    最近更新 更多