Google oauth2 javascript客户端无法在IE 9中运行 [英] Google oauth2 javascript client not working in IE 9

查看:139
本文介绍了Google oauth2 javascript客户端无法在IE 9中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Although the following code works correctly using Chrome (shows a popup that requests permission from the user to allow access to map and places data), IE 9 opens the popup form, but it is empty; when calling handleAuthClick method. I have tried adding setTimeouts but without effect. I ensured popups are allowed, and checked the popup page urls which are identical in Chrome and IE. Has anyone encountered this problem? Or can someone offer a work-around?

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');

        });
    });
}


推荐答案

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

What ending up solving this issue was increasing the setTimeout duration to 1000 from 10. The Google authorization pop-up was displayed with the correct sing-in information, rather than a blank screen.

这篇关于Google oauth2 javascript客户端无法在IE 9中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆