https://github.com/rbren/passport-phonegap-build
https://github.com/rbren/passport-phonegap-build
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/rbren/passport-phonegap-build
- Owner: rbren
- License: mit
- Created: 2015-01-05T18:53:16.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-05T18:53:46.000Z (over 11 years ago)
- Last Synced: 2025-02-10T07:14:37.694Z (over 1 year ago)
- Language: JavaScript
- Size: 141 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Passport-PhoneGap-Build
[Passport](http://passportjs.org/) strategy for authenticating with [PhoneGap Build](https://build.phonegap.com/)
using the OAuth 2.0 API.
This module lets you authenticate using GitHub in your Node.js applications.
By plugging into Passport, GitHub authentication can be easily and
unobtrusively integrated into any application or framework that supports
[Connect](http://www.senchalabs.org/connect/)-style middleware, including
[Express](http://expressjs.com/).
## Install
$ npm install passport-phonegap-build
## Usage
#### Configure Strategy
passport.use(new PhonegapBuildStrategy({
clientID: CLIENT_ID,
clientSecret: CLIENT_SECRET,
callbackURL: "http://127.0.0.1:3000/auth/phonegap/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 `'phonegap-build'` strategy, to
authenticate requests.
For example, as route middleware in an [Express](http://expressjs.com/)
application:
app.get('/auth/phonegap-build',
passport.authenticate('phonegap-build'));
app.get('/auth/phonegap-build/callback',
passport.authenticate('phonegap-build', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/');
});
## Credits
Inspired by Jared Hanson's Github Strategy:
- [Jared Hanson](http://github.com/jaredhanson)
## License
[The MIT License](http://opensource.org/licenses/MIT)