In Chrome/FF the following example works fine but there is a problem in IE9.
var clientId = 'XXXXXXXXX.apps.googleusercontent.com';
var apiKey = 'XXXXXXXX_XXXXXXXXXXXXXXXh1o';
var scopes = 'https://www.googleapis.com/auth/calendar';
function handleClientLoad() {
$(".modal").show();
gapi.client.setApiKey(apiKey);
window.setTimeout(checkAuth, 1);
}
function checkAuth() {
gapi.auth.authorize({ client_id: clientId, scope: scopes, immediate: true },
handleAuthResult);
}
function handleAuthResult(authResult) {
var authorizeButton = document.getElementById('authorize-button');
if (authResult) {
authorizeButton.style.visibility = 'hidden';
showPanel();
} else {
authorizeButton.style.visibility = '';
authorizeButton.onclick = handleAuthClick;
}
$(".modal").hide();
}
function handleAuthClick(event) {
gapi.auth.authorize({ client_id: clientId, scope: scopes, immediate: false }, handleAuthResult);
return false;
}
function showPanel() {
$("div#mainPanel").show("fast");
}
function makeApiCall() {
gapi.client.load('calendar', 'v3', function () {
var request = gapi.client.calendar.events.list({
'calendarId': 'primary'
});
request.execute(function (resp) {
for (var i = 0; i < resp.items.length; i++) {
var li = document.createElement('li');
li.appendChild(document.createTextNode(resp.items[i].summary));
document.getElementById('events').appendChild(li);
}
});
});
}
for some reason the authResult
variable is null in IE9 and handleAuthClick
click event popup a blank window instead of the Google credentials info.
What's the problem with IE9?