Passport-Dailymotion

Passport strategy for authenticating with Dailymotion using OAuth 2.0.

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

Install

$ npm install passport-dailymotion

Configure Strategy

The Dailymotion OAuth 2.0 authentication strategy authenticates users using a Dailymotion 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.

var DailymotionStrategy = require('passport-dailymotion').Strategy;

passport.use(new DailymotionStrategy({
    clientID: DM_API_KEY,
    clientSecret: DM_API_SECRET,
    callbackURL: "http://127.0.0.1:3000/auth/dailymotion/callback"
  },
  function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({ dailymotionId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

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

For example, as route middleware in an Express application:

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

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

Credits

License

Apache 2.0 License

Copyright (c) 2014 Mathieu Amiot <http://mathieu-amiot.fr/>

SEARCH FOR STRATEGIES

0STRATEGIES