The following code works well when using Chrome or Firefox. This is how Chrome / Firefox works.
- The user clicks the "Authorize" button.
- The browser opens a pop-up window requesting permission to access calendar data.
- The user clicks the Accept button.
- The popup automatically closes.
However, it does not work on IE. This is how IE is handled.
- The user clicks the "Authorize" button.
- The browser opens a pop-up window requesting permission to access calendar data.
- The user clicks the Accept button.
- The popup window becomes blank and does not close automatically.
Has anyone encountered similar problems? Or is there any work around? I was looking for a solution, but still could not find it. It seems that people are also facing similar problems.
API Google API Javascript.
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<script src='js/jquery-1.11.1.min.js'></script>
</head>
<body>
<button id="authorize-button" style="visibility: hidden">Authorize</button>
<script type="text/javascript">
var clientId = '{CLIENT ID}';
var apiKey = '{API KEY}';
var scopes = 'https://www.googleapis.com/auth/calendar';
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) {
console.log(authResult);
var authorizeButton = document.getElementById('authorize-button');
if (authResult && !authResult.error) {
authorizeButton.style.visibility = 'hidden';
makeApiCall();
} else {
authorizeButton.style.visibility = '';
authorizeButton.onclick = handleAuthClick;
}
}
function handleAuthClick(event) {
gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: false}, handleAuthResult);
return false;
}
function makeApiCall() {
gapi.client.load('calendar', 'v3', function() {
var request = gapi.client.calendar.calendarList.list();
request.execute(function(resp){
$.each( resp.items, function( key, value ) {
console.log(resp.items[key].id);
});
});
});
}
</script>
<script src="https://apis.google.com/js/client.js?onload=handleClientLoad"></script>
<div id="content"></div>
<p>Retrieves Calendar ID using the Google Plus API.</p>
</body>
</html>
< > :
, , , "authResult" , .
Chrome/Firefox :
[object Object]
{
_aa: "1",
access_token: "{ACCESS TOKEN}",
client_id: "{CLIENT ID}",
cookie_policy: undefined,
expires_at: "1414246430",
expires_in: "3600",
g_user_cookie_policy: undefined,
issued_at: "1414160131",
response_type: "token",
scope: "https://www.googleapis.com/auth/calendar",
state: [object Object],
token_type: "Bearer"
}
IE :
[object Object]
{
client_id: "{CLIENT ID}",
cookie_policy: undefined,
error: "immediate_failed",
error_subtype: "access_denied",
expires_at: "1414246430",
expires_in: "86400",
g_user_cookie_policy: undefined,
issued_at: "1414160030",
response_type: "token",
scope: "https://www.googleapis.com/auth/calendar",
state: "",
status: { }
}