Skip to content

passport strategy for authenticating with odnoklassniki

License

Notifications You must be signed in to change notification settings

dvpnt/passport-ok-strategy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

passport-ok-strategy

Build Status Coverage Status NPM Version

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

Install

$ npm i passport-ok-strategy

Usage

Configure Strategy

var passport = require('passport'),
    OdnoklassnikiStrategy = require('passport-ok-strategy').Strategy;

passport.use(new OdnoklassnikiStrategy({
    clientID: '<app id>',
    clientPublic: '<public key>',
    clientSecret: '<secret key>',
    callbackURL: 'http://localhost:3000/auth/odnoklassniki/callback'
  },
  function(accessToken, refreshToken, profile, cb) {
    User.findOrCreate({okId: profile.id}, function (err, user) {
      return cb(err, user);
    });
  }
));

Authenticate Requests

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

For example, as route middleware in an Express application:

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

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

License

The MIT License

About

passport strategy for authenticating with odnoklassniki

Resources

License

Stars

Watchers

Forks

Packages

No packages published