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



我对来自谷歌的关机通知邮件感到困惑,其中一封最近提到的邮件是

直接请求"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');
        }
    );
});

有好消息和坏消息。

好消息是,您没有使用任何加号范围

坏消息是您正在使用 plus API,该 API 也正在关闭,并且之前应该发送给您的电子邮件中提到了这一点。

具体来说,这段代码

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

调用"plus.people.me"API。

幸运的是,您应该能够通过将端点更改为

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

您可能还希望查看更现代的 People API,它的工作方式非常相似,并且稍微复杂一些,但可以提供其他配置文件字段。

相关内容

最新更新