Google oauth2 javascript客户端无法在IE 9中运行

ron*_*mbe 7 javascript internet-explorer oauth-2.0 google-oauth

虽然以下代码可以正常使用Chrome(显示一个弹出窗口,请求用户允许访问地图和放置数据),IE 9会打开弹出窗体,但它是空的; 调用handleAuthClick方法时.我尝试添加setTimeouts但没有效果.我确保允许弹出窗口,并检查Chrome和IE中相同的弹出页面URL.有谁遇到过这个问题?或者有人可以提供解决方案吗?

var clientId = '############.apps.googleusercontent.com';
var apiKey = '#A#A#A#A##';
var scopes = 'https://www.googleapis.com/auth/plus.me';

function handleClientLoad() {
    gapi.client.setApiKey(apiKey);
    window.setTimeout(checkAuth, 1);
}

function checkAuth() {
    gapi.auth.authorize({ client_id: clientId, scope: scopes, immediate: true }, handleAuthResult);
}

function handleAuthResult(authResult) {
    if (authResult && !authResult.error) {
        makeApiCall();
    } else {
    }
}

function handleAuthClick(event) {
    try {
        window.setTimeout(function () {
            gapi.auth.authorize({ client_id: clientId, scope: scopes, immediate: false }, handleAuthResult);
        }, 10);
    } catch (e) { alert(e.message); }
}
function makeApiCall() {
    gapi.client.load('plus', 'v1', function () {
        var request = gapi.client.plus.people.get({
            'userId': 'me'
        });
        request.execute(function (resp) {
            $(".google-signin").find("img").attr('src', resp.image.url).css('height', '32').css('width', '32');
            $("#login-msg").text('Welcome: ' + resp.displayName);
            $("img.vote").css('visibility', 'visible');

        });
    });
}
Run Code Online (Sandbox Code Playgroud)

ron*_*mbe 1

最终解决此问题的方法是将 setTimeout 持续时间从 10 增加到 1000。Google 授权弹出窗口显示了正确的登录信息,而不是空白屏幕。