0.4.1 • Published 10 months ago

passport-pr0gramm v0.4.1

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

passport-pr0gramm CI

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

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

Install

npm i passport-pr0gramm

Usage

Configure Strategy

The pr0gramm authentication strategy authenticates users using a pr0gramm 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 client ID, client secret, and callback URL.

passport.use(new Pr0grammStrategy({
    clientID: PR0GRAMM_CLIENT_ID,
    clientSecret: PR0GRAMM_CLIENT_SECRET,
    callbackURL: "http://127.0.0.1:3000/auth/pr0gramm/callback"
  },
  function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({ pr0grammId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

Use passport.authenticate(), specifying the "pr0gramm" strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.get("/auth/pr0gramm", function(req, res, next){
  passport.authenticate("pr0gramm")(req, res, next);
});

app.get("/auth/pr0gramm/callback", function(req, res, next){
  passport.authenticate("pr0gramm", {
    successRedirect: "/",
    failureRedirect: "/login"
  })(req, res, next);
});

Credits

Based on passport-reddit.

License

The ISC License

Original work Copyright (c) 2012-2013 Jared Hanson [http://jaredhanson.net/](http://jaredhanson.net/) Modified work Copyright (c) 2013 Dmytro Soltys [http://slotos.net/](http://slotos.net/) Modified work Copyright (c) 2013 Brian Partridge [http://brianpartridge.com/](http://brianpartridge.com/)

0.4.1

10 months ago

0.4.0

10 months ago

0.3.0

10 months ago

0.2.0

10 months ago

0.1.0

10 months ago