【问题标题】:getting error 400 on signing with google使用 google 签名时出现错误 400
【发布时间】: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


【解决方案1】:

经过长时间的搜索,我找到了神奇地解决我的问题的解决方案。 如错误 http://localhost 与注册的 JavaScript 源不匹配所示,我在 console.developer 站点的重定向 url 中设置了 http://localhost 而不是完整路径,它可以工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-11
    • 2021-12-23
    • 1970-01-01
    • 1970-01-01
    • 2020-11-21
    • 2013-09-27
    • 2015-08-18
    • 2015-11-15
    相关资源
    最近更新 更多