So I've been looking through old posts to try and debug my problem with gapi.auth.authorize... To be honest I'm new to this stuff so any help would be appreciated. My problem is that auth.init isn't working. As a result, checkAuth is never getting called. I'm also getting another error that I can't really make sense of:
var apiKey = 'AIzaSyB0mteDV5vDKFR-iAv4Fx4OC2gp1Yhqe9U';
function handleClientLoad() {
console.log('API key provided - authorizing client...');
// Step 2: Reference the API key
gapi.client.setApiKey(apiKey);
gapi.auth.init(checkAuth);
}
function checkAuth() {
console.log('entered checkAuth - authorizing...');
setTimeout(function() {
console.log("requesting auth");
gapi.auth.authorize({
client_id: clientId,
scope: scopes,
response_type:'token',
immediate: true
}, handleAuthResult);
}, 100);
}
function handleAuthResult(authResult) {
console.log('received authResult');
var authorizeButton = document.getElementById('authorize-button');
if (authResult && !authResult.error) {
console.log("auth. successful");
authorizeButton.style.visibility = 'hidden';
makeApiCall();
} else {
console.log('auth failed.');
authorizeButton.style.visibility = '';
authorizeButton.onclick = handleAuthClick;
}
}