Skip to content

pasupulaphani/passport-tripcase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Passport-TripCase

Authenticating with TripCase using the OAuth 2.0 API.

Supports Connect-style middleware, including Express.

Install

$ npm install passport-tripcase

Usage

Configure

passport.use(new TripCaseStrategy({
    clientID: TRIPCASE_CLIENT_ID,
    clientSecret: TRIPCASE_CLIENT_SECRET,
    callbackURL: "http://127.0.0.1:3000/auth/tripcase/callback",
    authorizationURL: 'https://www.tripcase.com/client_api_permissions',
    tokenURL: 'https://www.tripcase.com/developer_api/tokens',
    userProfileURL: 'https://www.tripcase.com/developer_api/users/me.json',
    userAgent: 'airmax-api'
  },
  function(accessToken, refreshToken, profile, done) {
    // profile.id for tripcase is primary_email
    User.findOrCreate({ tripcaseId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

Use passport.authenticate(), specifying the 'tripcase' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.get('/auth/tripcase',
  passport.authenticate('tripcase'));

app.get('/auth/tripcase/callback', 
  passport.authenticate('tripcase', { failureRedirect: '/login' }),
  function(req, res) {
    // Successful authentication, redirect home.
    res.redirect('/');
  });

Examples

For a complete, working example, refer to the login example.

Tests

$ npm install --dev
$ make test

Credits

License

The MIT License

Copyright (c) 2011-2013 Phaninder Pasupula <http://phaninder.com/>

About

OAuth2 for TripCase - works out of the box

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published