Fullcalendar + Private google calendar -
i m using full calendar web app project , sync google calendar of client, moment public calendar.
is there way sync private calendar ?
note : use 0auth identify , sync google account.
thanks
i think work private calendar using correct authorization.
authorizing requests oauth 2.0
all requests google calendar api must authorized authenticated user.
here sample create alexandre:
<script type="text/javascript"> var clientid = '<your-client-id>'; var apikey = '<your-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) { var authorizebutton = document.getelementbyid('authorize-button'); if (authresult && !authresult.error) { authorizebutton.style.visibility = 'hidden'; makeapicall(); } else { authorizebutton.style.visibility = ''; authorizebutton.onclick = handleauthclick; generatepubliccalendar(); } } function handleauthclick(event) { gapi.auth.authorize({client_id: clientid, scope: scopes, immediate: false}, handleauthresult); return false; } // load api , make api call. display results on screen. function makeapicall() { // step 4: load google+ api gapi.client.load('calendar', 'v3').then(function() { // step 5: assemble api request var request = gapi.client.calendar.events.list({ 'calendarid': '<your-calendar-id(the @gmail.com>' }); // step 6: execute api request request.then(function(resp) { var eventslist = []; var successargs; var successres; if (resp.result.error) { reporterror('google calendar api: ' + data.error.message, data.error.errors); } else if (resp.result.items) { $.each(resp.result.items, function(i, entry) { var url = entry.htmllink; // make urls each event show times in correct timezone //if (timezonearg) { // url = injectqscomponent(url, 'ctz=' + timezonearg); //} eventslist.push({ id: entry.id, title: entry.summary, start: entry.start.datetime || entry.start.date, // try timed. fall all-day end: entry.end.datetime || entry.end.date, // same url: url, location: entry.location, description: entry.description }); }); // call success handler(s) , allow return new events array successargs = [ eventslist ].concat(array.prototype.slice.call(arguments, 1)); // forward other jq args successres = $.fullcalendar.applyall(true, this, successargs); if ($.isarray(successres)) { return successres; } } if(eventslist.length > 0) { // here create calendar events options : //fullcalendar.events: eventslist (still looking methode remove current event , fill news event without recreating calendar. } return eventslist; }, function(reason) { console.log('error: ' + reason.result.error.message); }); }); } function generatepubliccalendar(){ // need normal fullcalendar googleapi when user isn't logged $('#calendar').fullcalendar({ googlecalendarapikey: '<your-key>', ... }); } </script> <script src="https://apis.google.com/js/client.js?onload=handleclientload"></script>
or
perform google apps domain-wide delegation of authority
in enterprise applications may want programmatically access users data without manual authorization on part. in google apps domains, domain administrator can grant third party applications domain-wide access users' data — referred domain-wide delegation of authority. delegate authority way, domain administrators can use service accounts oauth 2.0.
for additional detailed information, see using oauth 2.0 server server applications
hope helps!
Comments
Post a Comment