Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rbren/passport-phonegap-build
https://github.com/rbren/passport-phonegap-build
Last synced: 14 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/rbren/passport-phonegap-build
- Owner: rbren
- License: mit
- Created: 2015-01-05T18:53:16.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-01-05T18:53:46.000Z (almost 10 years ago)
- Last Synced: 2024-09-24T01:59:49.239Z (about 2 months 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)