Google 身份验证:popup_blocked_by_browser

时间:2021-06-21 14:58:43

标签: javascript mobile google-signin google-auth-library

我的 Web 应用程序是用纯 JS 编写的,并带有一点 JQuery。没有其他底层平台。 我正在使用 Google Auth 登录我的网络应用程序。这是相关代码:

let initGoogle = function() {
    gapi.load('auth2', function(){
        // Retrieve the singleton for the GoogleAuth library and set up the client.
        auth2 = gapi.auth2.init({

            client_id: 'my-client-id.apps.googleusercontent.com',
            cookiepolicy: 'single_host_origin',
            // Request scopes in addition to 'profile' and 'email'
            //scope: 'additional_scope'
        });
        attachSignin(document.getElementById('login_google'));
    });

    $("#login_google").click(() => {
        Utils.registerAnalytics("click", "login_google");
    })
};

let attachSignin = function(element) {
    console.log(element.id);
    auth2.attachClickHandler(element, {},
        async function(googleUser) {
            // do some other stuff
        }
    );
}

这工作得很好,但在某些情况下 - 尝试使用 Google 登录(在移动设备上点击 #login_google 按钮 - 会出现以下错误:

popup_blocked_by_browser

我正在阅读有关此错误的一些内容,并且我上面的代码相应地对齐。 仍然 - 这个问题到处都有。

我想念什么?

谢谢

0 个答案:

没有答案
相关问题