Hi,

In my application(in nodeJs) I am using goolge calendar to list out all 
events. I am using following code.


var GoogleCalendar = require('google-calendar');
var notLoggedIn = require('./middleware/not_logged_in');

var google_calendar = new GoogleCalendar.GoogleCalendar(
  'client-id', 
  'client-key',
  'http://localhost:3000/new');

module.exports = function(app) {
    
    app.all('/new', notLoggedIn, function(req, res){
        
        if(!req.query.code){
            //Redirect the user to Google's authentication form 
            google_calendar.getGoogleAuthorizeTokenURL(function(err, 
redirecUrl) {
                if(err) return res.send(500,err);
                return res.redirect(redirecUrl);
            });
    
        }
        else{
            
            //Get access_token from the code
            google_calendar.getGoogleAccessToken(req.query, function(err, 
access_token, refresh_token){
          
                if(err) return res.send(500,err);

                req.session.access_token = access_token;
                req.session.refresh_token = refresh_token;
                return res.redirect('/calendar_event/list');
                
            });
        }
    });
    
    app.get('/calendar_event/list', notLoggedIn, function(req, res, next){
        var access_token = req.session.access_token;
        users = req.session.user;
        if(!access_token){
            res.redirect('/new');
        }
        else{
            
            //Events.list
            var z = 0;
            google_calendar.listEvent(access_token, 'calender.id', 
function(err, events) {
                
                if(err)console.log(err);
                
                    
                    events = events.items;
                    res.render('calendar/events', {title: 'Event List', 
events: events, users: users});
                
            });
         
        }
        
    });
        
}; 

The problem it requires me login to access my calendar. Is there any way to 
avoid the login winow and it will autometically get access by the 
application.


Please help.
Thanks
Swarup

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to