passport-draugiem

0.1.2 • Public • Published

Passport-Draugiem

Passport strategy for authenticating with Draugiem

Install

npm install passport-draugiem

Usage

Configure Strategy

passport.use(new DraugiemStrategy({
    appId: DRAUGIEM_APP_ID,
    appKey: DRAUGIEM_APP_KEY,
    callbackURL: "http://localhost:3000/auth/draugiem/callback"
  },
  function(apiKey, profile, done) {
    User.findOrCreate({ draugiem: profile.uid }, function (err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

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

For example, as route middleware in an Express application:

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

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

Notes

For Node.js 18+ you can skip installing node-fetch with

npm i passport-twitter-2 --omit=optional

and use built-in fetch instead.

Credits

License

The MIT License

Copyright (c) 2022 Ēriks Remess

Package Sidebar

Install

npm i passport-draugiem

Weekly Downloads

8

Version

0.1.2

License

MIT

Unpacked Size

5.39 kB

Total Files

4

Last publish

Collaborators

  • eriks