I am using the Google Data JavaScript API and have problems with the AuthSub script working correctly. This is my script now:
google.load('gdata', '1');
function getCookie(c_name){
if(document.cookie.length>0){
c_start=document.cookie.indexOf(c_name + "=");
if(c_start!=-1){
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if(c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start, c_end));
}
}
return "";
}
function main(){
var scope = 'http://www.google.com/calendar/feeds/';
if(!google.accounts.user.checkLogin(scope)){
google.accounts.user.login();
} else {
var calendarService = new google.gdata.calendar.CalendarService('GoogleInc-jsguide-1.0');
var feedUri = 'http://www.google.com/calendar/feeds/default/allcalendars/full';
var callback = function(result) {
var entries = result.feed.entry;
var calendarEntry = entries[0];
var calendarTitle = calendarEntry.getTitle().getText();
alert('Calendar title = ' + calendarTitle);
}
var handleError = function(error) {
alert(error);
}
calendarService.getAllCalendarsFeed(feedUri, callback, handleError);
}
}
google.setOnLoadCallback(main);
However, when I launch this page, the page redirects me to the authentication page. After I authenticate it, send me to my page and then return me to the authentication page again. I turned on alerts to check if the token is installed and it does not seem to work. Does anyone have this problem?
source
share