我试图在网站上实施标准的Google登录选项,因为他们在此处建议:https://developers.google.com/identity/sign-in/web/。试图为网站实施Google登录,但该按钮未显示
作为一个开始,我还以为我只是遵循的基本指令(https://developers.google.com/identity/sign-in/web/devconsole-project),我仅仅使用他们的示例代码更多:
<html lang="en">
<head>
<meta name="google-signin-scope" content="profile email">
<meta name="google-signin-client_id" content="YOUR_CLIENT_ID.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script>
</head>
<body>
<div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"></div>
<script>
function onSignIn(googleUser) {
// Useful data for your client-side scripts:
var profile = googleUser.getBasicProfile();
console.log("ID: " + profile.getId()); // Don't send this directly to your server!
console.log("Name: " + profile.getName());
console.log("Image URL: " + profile.getImageUrl());
console.log("Email: " + profile.getEmail());
// The ID token you need to pass to your backend:
var id_token = googleUser.getAuthResponse().id_token;
console.log("ID Token: " + id_token);
};
</script>
</body>
</html>
(很明显,在一个替代的客户端id从他们的开发者控制台为我的网站生成)。如上所述,我在创建客户端ID时将该IP地址作为有效的JavaScript来源输入。但是,登录按钮甚至不出现。
我觉得自己像一个白痴,因为我确定有一些明显的步骤,我失踪了,但我一直无法弄清楚。任何建议?
我建议你阅读这篇文章 - http://www.sanwebe.com/2012/11/login-with-google-api-php,这对初学者很好,因为它提供了一个简单的登录系统,你可以复制 - 粘贴和玩。 –
我有完全相同的问题。它不会出现! – mesqueeb