2016-02-12 108 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的。

相關問題