谷歌,加上API关机,它将如何影响谷歌auth2登录的网站?

问题描述 投票:0回答:1

我很困惑与关闭通知邮件从谷歌最近所提到的邮件之一

项目直接请求“plus.me”范围受到影响。这个范围可能在一些电子邮件已经上市,即使不直接通过您的项目要求。我们对造成的任何不便,敬请见谅。

我使用下面的登录JS代码,我知道无论如何,由于谷歌,加上API停产不会影响?

<script async defer src="https://apis.google.com/js/api.js" onload="this.onload=function(){};HandleGoogleApiLibrary()" onreadystatechange="if (this.readyState === 'complete') this.onload()"></script>

<script type="text/javascript">
//google login starts
function HandleGoogleApiLibrary() {
    // Load "client" & "auth2" libraries
    gapi.load('client:auth2', {
        callback: function() {
            // Initialize client library
            // clientId & scope is provided => automatically initializes auth2 library
            gapi.client.init({
                apiKey: 'API KEY HERE',
                clientId: 'XXXXXXXXXXXXXXXXX.apps.googleusercontent.com',
                scope: 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'                        
            }).then(
                // On success
                function(success) {
                    // After library is successfully loaded then enable the login button
                    //CODE AFTER SUCCESS
                }, 
                // On error
                function(error) {                    
                    alert('Error : Failed to Load Library');
                }
            );
        },
        onerror: function() {
            // Failed to load libraries
        }
    });
}

// Click on login button
$("#login-button").on('click', function() {
    // API call for Google login
    gapi.auth2.getAuthInstance().signIn().then(
        // On success
        function(success) {
            // API call to get user information
            gapi.client.request({ path: 'https://www.googleapis.com/plus/v1/people/me' }).then(
                // On success
                function(success) {
                    console.log(success);
                    var user_info = JSON.parse(success.body);                       
                    //VALIDATION                 
                },
                // On error
                function(error) {                                               
                    alert('Error : Failed to login');
                }
            );
        },
        // On error
        function(error) {
            $("#login-button").removeAttr('disabled');
            alert('Error : Login Failed');
        }
    );
});
google-plus google-signin google-api-client google-auth-library
1个回答
3
投票

有一个好消息和一个坏消息。

好消息是,你不使用任何加范围的。

坏消息是,你正在使用的加API,它也被关闭,这是在本来应该发送给您的一封电子邮件中所述。

具体地,该块的代码:

gapi.client.request({ path: 'https://www.googleapis.com/plus/v1/people/me' }).then(

所谓的 “plus.people.me” API。

幸运的是,你应该能够切换到不同的API,如"userinfo" API,通过改变端点

https://www.googleapis.com/oauth2/v2/userinfo

您可能还希望寻找到更现代的People API,这非常相似的作品,并且是稍微复杂一些,但可以提供其他个人资料字段。

© www.soinside.com 2019 - 2024. All rights reserved.