Javascript Google Plus登录-未知RPC服务错误

Javascript Google Plus登录-未知RPC服务错误,javascript,login,google-plus,Javascript,Login,Google Plus,我已经在我的网站上集成了Google Plus登录,一切都很好,直到昨天下午5点左右,我的G Plus登录在Chrome上停止工作。代码没有更改,但按钮不再工作,鼠标悬停不会产生手(仅文本选择),突然控制台中出现了几个未知的RPC错误: Uncaught TypeError: Cannot read property 'prototype' of undefined VM2122:6 Unknown RPC service: _ready cb=gapi.loaded_0:64 Unknown

我已经在我的网站上集成了Google Plus登录,一切都很好,直到昨天下午5点左右,我的G Plus登录在Chrome上停止工作。代码没有更改,但按钮不再工作,鼠标悬停不会产生手(仅文本选择),突然控制台中出现了几个未知的RPC错误:

Uncaught TypeError: Cannot read property 'prototype' of undefined VM2122:6
Unknown RPC service: _ready cb=gapi.loaded_0:64
Unknown RPC service: _ready cb=gapi.loaded_0:64
Unknown RPC service: _resizeMe cb=gapi.loaded_0:64
我以为这与我的Google Plus登录按钮HTML有关,但我一直无法找到问题所在。我发现它没有帮助,我没有使用jQuery创建按钮,只是纯HTML:

<div id="gConnect">
    <button class="g-signin"
        data-scope="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email"
        data-requestvisibleactions="http://schemas.google.com/AddActivity"
        data-clientId="REDACTED"
        data-callback="onSignInCallback"
        data-theme="dark"
        data-cookiepolicy="single_host_origin">
    </button>
</div>

在我的JS中:

var helper = (function() {
    var BASE_API_PATH = 'plus/v1/';


    return {
        /**
         * Hides the sign in button and starts the post-authorization operations.
         *
         * @param {Object} authResult An Object which contains the access token and
         *   other authentication information.
         */


        onSignInCallback: function(authResult) {
          gapi.client.load('plus','v1', function(){
            // $('#authResult').html('Auth Result:<br/>');
            // for (var field in authResult) {
            //   $('#authResult').append(' ' + field + ': ' +
            //       authResult[field] + '<br/>');
            // }


            if (authResult['access_token']) {
              gapi.auth.setToken(authResult); // Store the returned token.  Unnecessary?
              $('#loggedIn').show('slow');
              $('#gConnect').fadeOut('slow');
              helper.profile();

            } else if (authResult['error']) {
              // There was an error, which means the user is not signed in.
              // As an example, you can handle by writing to the console:
              console.log('The user is not signed in.');
              $('#loggedIn').hide('slow');
              $('#gConnect').show();
            }

            // console.log('authResult', authResult);
          });
        },

        /**
         * Calls the OAuth2 endpoint to disconnect the app for the user.
         */

        disconnect: function() {
          // Revoke the access token.
          $.ajax({
            type: 'GET',
            url: 'https://accounts.google.com/o/oauth2/revoke?token=' +
                gapi.auth.getToken().access_token,
            async: false,
            contentType: 'application/json',
            dataType: 'jsonp',
            success: function(result) {
              console.log('revoke response: ' + result);
              $('#loggedIn').hide();
              $('#profileImg').empty();
              $('#greeting').empty();
              $('#gConnect').show();
            },
            error: function(e) {
              console.log(e);
            }
          });
        },

        /**
         * Gets and renders the list of people visible to this app.
         */
        people: function() {
          var request = gapi.client.plus.people.list({
            'userId': 'me',
            'collection': 'visible'
          });
          request.execute(function(people) {
            $('#visiblePeople').empty();
            $('#visiblePeople').append('Number of people visible to this app: ' +
                people.totalItems + '<br/>');
            for (var personIndex in people.items) {
              person = people.items[personIndex];
              $('#visiblePeople').append('<img src="' + person.image.url + '">');
            }
          });
        },

        /**
         * Gets and renders the currently signed in user's profile data.
         */
        profile: function() {

            gapi.client.load('oauth2', 'v2', function() {

                // get email      
                var request = gapi.client.oauth2.userinfo.get();
                request.execute(function(obj) {
                  userInfo.setEmail(obj.email);
                });

                // get profile
                var request = gapi.client.plus.people.get( {'userId' : 'me'} );
                request.execute(function(profile) {
                  userInfo.setProfile(profile);
                });

            });

        }
    };   
})();


function onSignInCallback(authResult) {
  helper.onSignInCallback(authResult);
}
var helper=(函数(){
var BASE_API_PATH='plus/v1/';
返回{
/**
*隐藏“登录”按钮并启动授权后操作。
*
*@param{Object}authResult包含访问令牌和
*其他身份验证信息。
*/
OnSignncCallback:函数(authResult){
load('plus','v1',function(){
//$('#authResult').html('Auth Result:
'); //for(authResult中的变量字段){ //$('#authResult')。追加(''+字段+':'+ //authResult[field]+'
'); // } if(authResult['access_token']){ gapi.auth.setToken(authResult);//存储返回的令牌。不需要吗? $('#loggedIn')。show('slow'); $(“#gConnect”).fadeOut('slow'); helper.profile(); }else if(authResult['error']){ //出现错误,这意味着用户未登录。 //例如,您可以通过写入控制台来处理: log('用户未登录'); $('#loggedIn')。隐藏('slow'); $('#gConnect').show(); } //log('authResult',authResult); }); }, /** *调用OAuth2端点以断开该用户的应用程序。 */ 断开连接:函数(){ //撤消访问令牌。 $.ajax({ 键入:“GET”, 网址:'https://accounts.google.com/o/oauth2/revoke?token=' + gapi.auth.getToken().access\u令牌, async:false, contentType:'应用程序/json', 数据类型:“jsonp”, 成功:功能(结果){ log('撤销响应:'+结果); $('#loggedIn').hide(); $('#profileImg').empty(); $(“#问候语”).empty(); $('#gConnect').show(); }, 错误:函数(e){ 控制台日志(e); } }); }, /** *获取并呈现此应用可见的人员列表。 */ 人员:功能(){ var request=gapi.client.plus.people.list({ 'userId':'me', “集合”:“可见” }); 请求.执行(功能(人员){ $(“#visiblePeople”).empty(); $(“#visiblePeople”).append('此应用程序可见的人数:'+ people.totalItems+“
”); for(person.items中的变量personIndex){ person=people.items[personIndex]; $(“#visiblePeople”).append(“”); } }); }, /** *获取并呈现当前登录用户的配置文件数据。 */ 配置文件:函数(){ load('oauth2','v2',function(){ //收到电子邮件 var request=gapi.client.oauth2.userinfo.get(); 请求执行(功能(obj){ userInfo.setEmail(obj.email); }); //获取配置文件 var request=gapi.client.plus.people.get({'userId':'me'}); 执行(函数(配置文件){ userInfo.setProfile(profile); }); }); } }; })(); 函数onSignncCallback(authResult){ helper.onSigningCallback(authResult); }

我还没有找到任何关于Google+API中的更改的文档,也没有找到任何其他有这个特定问题的人。另外一条奇怪的信息是,我仍然可以使用移动浏览器(Android)登录,但应用程序的功能受到了损害(超出了本文的范围)。

尝试在浏览器上启用第三方cookie,它应该可以工作:)

如果这是正确的,你能详细说明一下吗?指向一些博客文章或文档?请记住,这是一个维基网站,而不仅仅是一个讨论板。谢谢,这确实是个问题。很想知道为什么昨天这种行为发生了变化,以及在哪里有记录。我昨天没有改变我的cookies策略,而且它(尽管没有cookies)在之前的几个月里一直有效,没有禁用第三方cookies。。。