2016-02-12 112 views
0

我正在尝试整合Google的登录功能。在本地python SimpleHTTPServer上运行一个基本示例,除了getBasicProfile()方法返回一个空对象这一事实之外,工作正常。它不显示姓名,电子邮件,IMAGEURL,ID ...Google Sign-In - 返回空白个人资料

的片段:

<html> 
<head> 
    <script src="https://apis.google.com/js/platform.js" async defer></script> 
    <meta name="google-signin-client_id" content="123456789_fake_987654321.apps.googleusercontent.com"> 
</head> 
<body> 

    <div class="g-signin2" data-onsuccess="onSignIn"></div> 
    <a href="#" onclick="signOut();">Sign out</a> 

    <script> 
     function onSignIn(googleUser) { 
      var profile = googleUser.getBasicProfile(); 
      console.log(profile.getId()); 
      console.log(profile.getName()); 
      console.log(profile.getImageUrl()); 
      console.log(profile.getEmail()); 
     } 
     function signOut() { 
      var auth2 = gapi.auth2.getAuthInstance(); 
      auth2.signOut().then(function() { 
       console.log('User signed out.'); 
      }); 
     } 
    </script> 

</body> 
</html> 

的API打开一个新窗口,让我进入我的凭据,并记录了我和退出没有任何问题。只有定义的googleUser对象继续返回空属性。

任何想法?

回答

0

发现,蟒蛇SimpleHTTPServer使用端口8000

我不得不添加http://localhost:8000,与端口号,而不是http://localhost,到禁区JavaScript源和重定向我的谷歌的客户端ID的URI的。

相关问题