通过使用此代码检查用户是否授权您的应用
gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: true}, handleAuthResult);
如果你设置 immidiate true 那么它不会显示 popup 如果 false 它将向用户显示弹出窗口
在句柄AuthResult
handleAuthResult = 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 = handleAuthClick;
}
}
handleAuthClick = function (event) {
gapi.auth.authorize({
client_id: clientId,
scope: scopes,
immediate: false
}, handleAuthResult);
return false;
}
我想它会帮助你