passport-payco

version download status status Standard - JavaScript Style Guide

Passport stratege for autenticating with Payco using the OAuth 2.0 API.

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

Install

$ npm install passport-payco

Usage

Configure Strategy

The Payco authentication strategy authenticates users using a Payco 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 clientID, clientSecret, and callback URL.

var PaycoStrategy = require('passport-payco').Strategy

passport.use(new PaycoStrategy({
    clientID: YOUR PAYCO CLIENT ID,
    clientSecret: YOUR PAYCO CLIENT SECRET,
    callbackURL: 'http://127.0.0.1:3000/auth/payco/callback'
  }, function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({ id: profile.id }, function (err, user) {
      return done(err, user)
    })
  }
))

Authenticate Requests

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

For example, as route middleware in an Express

app.get('/auth/payco',
  passport.authenticate('payco')
)

app.get('/auth/payco/callback',
  passport.authenticate('payco', {
    failureRedirect: '/login',
    successRedirect : '/'
  })
)

Examples

Thanks to

License

The MIT License

Copyright (c) 2017 egg

SEARCH FOR STRATEGIES

0STRATEGIES