Skip to content
This repository
Newer
Older
100644 75 lines (51 sloc) 2.286 kb
9568133f »
2012-01-11 Initial commit.
1 # Passport-Ohloh
2
3 [Passport](https://github.com/jaredhanson/passport) strategy for authenticating
f6811e23 »
2012-01-11 Update README.
4 with [Ohloh](http://www.ohloh.net/) using the OAuth 1.0 API.
9568133f »
2012-01-11 Initial commit.
5
4a45d37a »
2013-01-24 Update project metadata.
6 This module lets you authenticate using Ohloh in your Node.js applications.
7 By plugging into Passport, Ohloh authentication can be easily and
8 unobtrusively integrated into any application or framework that supports
9 [Connect](http://www.senchalabs.org/connect/)-style middleware, including
10 [Express](http://expressjs.com/).
11
12 ## Install
9568133f »
2012-01-11 Initial commit.
13
14 $ npm install passport-ohloh
15
b770b3b2 »
2012-01-11 Update README.
16 ## Usage
17
18 #### Configure Strategy
19
20 The Ohloh authentication strategy authenticates users using a Ohloh account
21 and OAuth tokens. The strategy requires a `verify` callback, which accepts
22 these credentials and calls `done` providing a user, as well as `options`
23 specifying a consumer key, consumer secret, and callback URL.
24
25 passport.use(new OhlohStrategy({
26 consumerKey: OHLOH_API_KEY,
27 consumerSecret: OHLOH_CONSUMER_SECRET,
28 callbackURL: "http://127.0.0.1:3000/auth/ohloh/callback"
29 },
30 function(token, tokenSecret, profile, done) {
31 User.findOrCreate({ ohlohId: profile.id }, function (err, user) {
32 return done(err, user);
33 });
34 }
35 ));
36
37 #### Authenticate Requests
38
39 Use `passport.authenticate()`, specifying the `'ohloh'` strategy, to
40 authenticate requests.
41
42 For example, as route middleware in an [Express](http://expressjs.com/)
43 application:
44
45 app.get('/auth/ohloh',
4a45d37a »
2013-01-24 Update project metadata.
46 passport.authenticate('ohloh'));
b770b3b2 »
2012-01-11 Update README.
47
48 app.get('/auth/ohloh/callback',
49 passport.authenticate('ohloh', { failureRedirect: '/login' }),
50 function(req, res) {
51 // Successful authentication, redirect home.
52 res.redirect('/');
53 });
54
f6811e23 »
2012-01-11 Update README.
55 ## Examples
b770b3b2 »
2012-01-11 Update README.
56
57 For a complete, working example, refer to the [login example](https://github.com/jaredhanson/passport-ohloh/tree/master/examples/login).
58
f6811e23 »
2012-01-11 Update README.
59 ## Tests
60
61 $ npm install --dev
62 $ make test
63
c11a6f30 »
2012-02-21 Conform to latest conventions.
64 [![Build Status](https://secure.travis-ci.org/jaredhanson/passport-ohloh.png)](http://travis-ci.org/jaredhanson/passport-ohloh)
65
9568133f »
2012-01-11 Initial commit.
66 ## Credits
67
68 - [Jared Hanson](http://github.com/jaredhanson)
69
70 ## License
71
4a45d37a »
2013-01-24 Update project metadata.
72 [The MIT License](http://opensource.org/licenses/MIT)
9568133f »
2012-01-11 Initial commit.
73
4a45d37a »
2013-01-24 Update project metadata.
74 Copyright (c) 2012-2013 Jared Hanson <[http://jaredhanson.net/](http://jaredhanson.net/)>
Something went wrong with that request. Please try again.