Javascript 使用谷歌api登录我的网站

Javascript 使用谷歌api登录我的网站,javascript,google-api,google-plus,google-api-client,google-authentication,Javascript,Google Api,Google Plus,Google Api Client,Google Authentication,我正在尝试使用google登录我的网站。我将代码放在jsp页面html代码中: <span id="signinButton"> <span class="g-signin" data-callback="signinCallback" data-clientid="*********" data-cookiepolicy="single_host_origin" data-requestvisibleactions="http://schema.org/AddAction"

我正在尝试使用google登录我的网站。我将代码放在jsp页面html代码中:

<span id="signinButton">
 <span
class="g-signin"
data-callback="signinCallback"
data-clientid="*********"
data-cookiepolicy="single_host_origin"
data-requestvisibleactions="http://schema.org/AddAction"
data-scope="https://www.googleapis.com/auth/plus.login">
 </span>
 </span>
如果将数据作用域地址放在http上,则出现错误:

  • 那是个错误
  • 错误:无效的\u请求

    请求\u可见\u范围不允许的操作

  • 那是个错误
  • 错误:原点不匹配

    应用程序:项目默认服务帐户


    如何解决此问题。我希望用户配置文件详细信息使用google api?

    删除
    数据请求访问操作=”http://schema.org/AddAction“
    确保在您的应用程序允许来源列表中注册了执行代码的确切URL和路径。将范围更改为
    data scope=“profile”

    我删除了我得到的错误400。那是个错误。错误:无效的\u作用域某些请求的作用域无效。{invalid=[}但现在我不仅在线测试了localhost,还测试了put data scope=“profile”我得到错误:400。这是一个错误。错误:源代码\u不匹配应用程序:项目默认服务帐户正如我在回答中所说的,您必须确保应用程序设置的源代码设置正确。再次出现一个问题,我单击g+登录按钮工作正常,没有显示错误,但在浏览器控制台中显示一条错误消息。[名为的回调函数]找不到“signinCallback”。未调用返回回调函数。如何解决此问题?请帮助我。。。
    (function() {
      var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
      po.src = 'https://apis.google.com/js/client:plusone.js';
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
    })();
    
     function signinCallback(authResult) {
          if (authResult['status']['signed_in']) {
            // Update the app to reflect a signed in user
            // Hide the sign-in button now that the user is authorized, for example:
            document.getElementById('signinButton').setAttribute('style', 'display: none');
            var request = gapi.client.plus.people.get({
                  'userId' : 'me'
                });
            request.execute(function(resp) {
                  console.log('ID: ' + resp.id);
                  console.log('Display Name: ' + resp.displayName);
                  console.log('Image URL: ' + resp.image.url);
                  console.log('Profile URL: ' + resp.url);
                });
          } else {
            // Update the app to reflect a signed out user
            // Possible error values:
            //   "user_signed_out" - User is signed-out
            //   "access_denied" - User denied access to your app
            //   "immediate_failed" - Could not automatically log in the user
            console.log('Sign-in state: ' + authResult['error']);
          }
        }