Skip to content

LikeCoin (like.co) authentication strategy for Passport and Node.js.

License

Notifications You must be signed in to change notification settings

thematters/passport-likecoin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

passport-likecoin

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


Install

$ npm install @matters/passport-likecoin

Usage

Configure Strategy

The LikeCoin authentication strategy authenticates users using a LikeCoin account and OAuth 2.0 tokens. The app ID and secret obtained when creating an application are supplied as options when creating the strategy. The strategy also requires a verify callback, which receives the access token and optional refresh token, as well as profile which contains the authenticated user's LikeCoin profile. The verify callback must call cb providing a user to complete authentication.

passport.use(new LikeCoinStrategy({
    clientID: LIKECOIN_CLIENT_ID,
    clientSecret: LIKECOIN_CLIENT_SECRET,
    callbackURL: "http://localhost:3000/auth/likecoin/callback"
  },
  function(accessToken, refreshToken, params, profile, cb) {c
    const likerId = params.user;

    User.findOrCreate({ likerId }, function (err, user) {
      return cb(err, user);
    });
  }
));

Authenticate Requests

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

For example, as route middleware in an Express application:

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

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

License

The MIT License

About

LikeCoin (like.co) authentication strategy for Passport and Node.js.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published