【发布时间】:2015-08-27 06:37:50
【问题描述】:
我想在我的网站中创建谷歌登录,使用的代码来自谷歌开发者网站here,我正在使用 php 进行编码,我的代码是
<!DOCTYPE html>
<html>
<head>
<title>Google Login</title>
<meta name="google-signin-client_id" content="9252517****-o9350mh2vrp58maddlv0aeitkd0c****.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script>
function onSignIn(googleUser)
{
var profile = googleUser.getBasicProfile();
console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
console.log('Name: ' + profile.getName());
console.log('Image URL: ' + profile.getImageUrl());
console.log('Email: ' + profile.getEmail());
}
function signOut()
{
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function ()
{
console.log('User signed out.');
});
}
</script>
</head>
<body>
<div align="center" margin-top="100px">
<div class="g-signin2" data-onsuccess="onSignIn"></div>
<a href="#" onclick="signOut();">Sign out</a>
</div>
</body>
</html>
登录后我收到类似这样的错误错误:redirect_uri_mismatch 请求中的 JavaScript 源:http://localhost 与注册的 JavaScript 源不匹配。 您可以检查错误here。
请帮我解决这个问题。
【问题讨论】:
-
我认为你不能在 localhost 上使用谷歌登录
标签: google-signin