Javascript 谷歌登录-返回空配置文件
我正在尝试整合谷歌的登录。在本地python SimpleHTTPServer上运行一个基本示例,效果很好,只是getBasicProfile()方法返回一个空对象。它不显示名称、电子邮件、图像URL、ID 片段:Javascript 谷歌登录-返回空配置文件,javascript,google-api,google-signin,Javascript,Google Api,Google Signin,我正在尝试整合谷歌的登录。在本地python SimpleHTTPServer上运行一个基本示例,效果很好,只是getBasicProfile()方法返回一个空对象。它不显示名称、电子邮件、图像URL、ID 片段: <html> <head> <script src="https://apis.google.com/js/platform.js" async defer></script> <meta name="goog
<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>
函数onSignIn(谷歌用户){
var profile=googleUser.getBasicProfile();
console.log(profile.getId());
console.log(profile.getName());
log(profile.getImageUrl());
console.log(profile.getEmail());
}
函数签出(){
var auth2=gapi.auth2.getAuthInstance();
auth2.signOut().then(函数(){
log('User signed out');
});
}
api将打开一个新窗口,允许我输入凭据,并让我在没有任何问题的情况下登录和注销。只有已定义的googleUser对象继续返回空属性
有什么想法吗 发现python SimpleHTTPServer正在使用端口8000 我必须添加端口号,而不是,到受限的JavaScript源代码中,并重定向我的Google客户端ID的URI