使用Azure移动服务Javascript客户端SDK进行Google登录重定向错误

时间:2016-02-08 06:27:44

标签: azure azure-mobile-services

当我的网络客户端尝试使用Azure Mobile Javascript sdk登录google时,它给了我一个错误。

<html>
<head>
  <script src="https://ajax.aspnetcdn.com/ajax/mobileservices/MobileServices.Web-1.2.7.min.js"></script>

  <script> 
  function signIn(){    
     var MobileServiceClient = WindowsAzure.MobileServiceClient;
     var client = new MobileServiceClient('https://thehome.azurewebsites.net', 'xxxx');

    client.login("google").done(function (results) {
         alert("You are now logged in as: " + results.userId);
    }, function (err) {
        alert("Error: " + err);
    });
  }
  </script>

</head>

<body>
    <button onclick="signIn()">Click me</button>
</body>

</html>

我使用了来自https://azure.microsoft.com/en-us/documentation/articles/mobile-services-html-how-to-use-client-library/的示例代码。 如果我点击按钮,我会收到以下错误。

Cannot GET /login/google?completion_type=postMessage&completion_origin=https%3A%2F%2Fthehome.azurewebsites.net

我的iOS应用程序适用于服务器应用程序,但只有Web客户端有此问题。

有什么建议吗?

1 个答案:

答案 0 :(得分:1)

请记住,登录后,Google等提供商的登录会从服务器到服务器执行ping操作。

现在,它抱怨您在azure thehome 中的服务不存在。

请按照本指南配置您的Google帐户,使其与移动服务配合使用:

https://azure.microsoft.com/en-us/documentation/articles/mobile-services-how-to-register-google-authentication/