Skip to content

dailycred/passport-dailycred

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Node.js Using Passport

Passport strategy for authenticating with Dailycred using the OAuth 2.0 API.

This module lets you authenticate using Dailycred authentication in your Node.js applications. By plugging into Passport, Dailycred authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.

Installation

$ npm install passport-dailycred

Usage

Configure Strategy

The Dailycred authentication strategy authenticates users using a Dailycred account and OAuth 2.0 tokens. The strategy requires a verify callback, which accepts these credentials and calls done providing a user, as well as options specifying a app ID, app secret, and callback URL.

passport.use(new DailycredStrategy({
    clientID: DAILYCRED_APP_ID,
    clientSecret: DAILYCRED_SECRET,
    callbackURL: "http://localhost:3000/auth/dailycred/callback"
  },
  function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({ dailycredId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

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

For example, as route middleware in an Express application:

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

app.get('/auth/signin',
  passport.authenticate('dailycred', {action:'signin'})); //uses param ?action=signin

//setup a route for each provider, so you can use /auth/facebook, etc
var providers = ["facebook","google","twitter"];
var provider;
for (i in providers){
  provider = providers[i];
  app.get("/auth/"+provider,
    passport.authenticate('dailycred', {identity_provider: provider}))
}

app.get('/auth/dailycred/callback',
  passport.authenticate('dailycred', { 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

Build Status

About

An NPM module for using an authentication strategy with Dailycred on Passport

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •