需要在js中发出auth请求,但浏览器不支持弹出窗口。有没有办法重定向到新的网址或在应用程序的html5页面中显示请求
答案 0 :(得分:1)
使用此代码检查用户是否授权您的应用
gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: true}, callbackAuthResult);
注意:immediate:true
如果你设置立即为真,那么它不会显示弹出窗口。
callbackAuthResult
中的:
callbackAuthResult = function (authResult) {
var authorizeButton = document.getElementById('authorize-button');
if (authResult && !authResult.error) {
authorizeButton.style.display = 'none';
// do your processing here
} else {
authorizeButton.style.display = 'block';
authorizeButton.onclick = callbackAuthClick;
}
}
callbackAuthClick = function (event) {
gapi.auth.authorize({
client_id: clientId,
scope: scopes,
immediate: false
}, handleAuthResult);
return false;
}