Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 2853 lines (2277 sloc) 92.298 kb
2912ca1 @bnoguchi Added a README to explore what the API might look like.
authored
1 everyauth
2 ==========
3
4 Authentication and authorization (password, facebook, & more) for your node.js Connect and Express apps.
5
d896a7d @bnoguchi Working link to nodetuts screencast
authored
6 There is a NodeTuts screencast of everyauth [here](http://vimeo.com/26532298)
bc178ea @bnoguchi Added link to NodeTuts screencast to README
authored
7
20130ad @bnoguchi Add new Twitter and Google Groups info for everyauth
authored
8 There is also a Google Groups (recently created)
9 [here](http://groups.google.com/group/everyauth) to post questions and discuss
10 potential ideas and extensions to the library.
11
a55bb7a @bnoguchi Updated README to include information about how to configure auth for…
authored
12 So far, `everyauth` enables you to login via:
13
d1e40e6 @bnoguchi Left align README table take-3
authored
14 <table style="text-align:left">
42b3994 @bnoguchi Trying out new table-based formatting in README
authored
15 <thead>
8449f38 @bnoguchi Left align the README table headers
authored
16 <tr>
1f57b6c @bnoguchi Close <tbody> and <table> tags in README
authored
17 <th> Authenticate Via <th> Credits
1912f53 @bnoguchi One more table style fix in README
authored
18 </tr>
26f2e3d @bnoguchi Close <thead> tag
authored
19 </thead>
cdaf3ac @bnoguchi Re-ordered modules in README
authored
20 <tbody>
2832729 @bnoguchi README table markup fixes
authored
21 <tr> <td> Password <td>
cdaf3ac @bnoguchi Re-ordered modules in README
authored
22 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/facebook.ico" style="vertical-align:middle"> Facebook <td>
2832729 @bnoguchi README table markup fixes
authored
23 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/twitter.ico" style="vertical-align:middle"> Twitter <td>
cdaf3ac @bnoguchi Re-ordered modules in README
authored
24 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/google.ico" style="vertical-align:middle"> Google <td>
25 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/google.ico" style="vertical-align:middle"> Google Hybrid <td> <a href="https://github.com/rocketlabsdev">RocketLabs Development</a>
2832729 @bnoguchi README table markup fixes
authored
26 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/linkedin.ico" style="vertical-align:middle"> LinkedIn <td>
ed4a561 @bnoguchi Convert md links to <a> links inside <table> in README
authored
27 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/dropbox.ico" style="vertical-align:middle"> Dropbox <td> <a href="https://github.com/torgeir">Torgeir</a>
2832729 @bnoguchi README table markup fixes
authored
28 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/tumblr.jpg" style="vertical-align:middle"> Tumblr <td>
7484bc2 Updated readme to include Evernote
Danny Amey authored
29 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/evernote.ico" style="vertical-align:middle"> Evernote <td> <a href="https://github.com/dannyamey">Danny Amey</a>
2832729 @bnoguchi README table markup fixes
authored
30 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/github.ico" style="vertical-align:middle"> Github <td>
31 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/instagram.ico" style="vertical-align:middle"> Instagram <td>
32 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/foursquare.ico" style="vertical-align:middle"> Foursquare <td>
cdaf3ac @bnoguchi Re-ordered modules in README
authored
33 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/yahoo.ico" style="vertical-align:middle"> Yahoo! <td>
34 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/justintv.ico" style="vertical-align:middle"> Justin.tv <td> <a href="https://github.com/slickplaid">slickplaid</a>
35 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/vimeo.gif" style="vertical-align:middle"> Vimeo <td> <a href="https://github.com/slickplaid">slickplaid</a>
2832729 @bnoguchi README table markup fixes
authored
36 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/37signals.ico" style="vertical-align:middle"> 37signals
37 (Basecamp, Highrise, Backpack, Campfire) <td>
cdaf3ac @bnoguchi Re-ordered modules in README
authored
38 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/readability.ico" style="vertical-align:middle"> Readability <td> <a href="https://github.com/alfrednerstu">Alfred Nerstu</a>
861dbe4 Update sizes of skyrock and angellist icons in README
Brian Noguchi authored
39 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/angellist.ico" style="vertical-align:middle" width="16px" height="16px"> AngelList <td>
bd820f6 @nanek updated README.md link format, updated spacing on return
nanek authored
40 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/dwolla.ico" style="vertical-align:middle"> Dwolla <td> <a href="https://github.com/nanek">Kenan Shifflett</a>
4e623d1 @bnoguchi Re-order auth modules in README
authored
41 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/osm.ico" style="vertical-align:middle"> OpenStreetMap <td> <a href="https://github.com/christophlsa">Christoph Giesel</a>
2a745bf @meritt Change branch for icon
meritt authored
42 <tr> <td> <img src="https://github.com/meritt/everyauth/raw/vkontakte/media/vkontakte.ico" style="vertical-align:middle"> VKontakte (Russian Social Network) <td> <a href="https://github.com/meritt">Alexey Simonenko</a>
d0d1fd6 @bnoguchi Merge branch 'master' of https://github.com/biggora/everyauth into bi…
authored
43 <tr> <td> <img src="https://github.com/biggora/everyauth/raw/master/media/mailru.ico" style="vertical-align:middle"> Mail.ru (Russian Social Network) <td> <a href="https://github.com/biggora">Alexey Gordeyev</a>
861dbe4 Update sizes of skyrock and angellist icons in README
Brian Noguchi authored
44 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/skyrock.ico" style="vertical-align:middle" width="16px" height="16px"> Skyrock <td> <a href="https://github.com/srod">Rodolphe Stoclin</a>
cdaf3ac @bnoguchi Re-ordered modules in README
authored
45 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/gowalla.ico" style="vertical-align:middle"> Gowalla <td> <a href="https://github.com/andykram">Andrew Kramolisch</a>
4b5c5a2 @bnoguchi Resize tripit icon
authored
46 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/tripit.png" style="vertical-align:middle"> TripIt <td> <a href="https://github.com/pirxpilot">Damian Krzeminski</a>
47 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/500px.ico" style="vertical-align:middle"> 500px <td> <a href="https://github.com/dannyamey">Danny Amey</a>
b9bda68 @cleishm Add SoundCloud OAuth2 support
cleishm authored
48 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/soundcloud.ico" style="vertical-align:middle"> SoundCloud <td> <a href="https://github.com/chrisleishman">Chris Leishman</a>
57d21ad @ainoya fix README.md
ainoya authored
49 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/mixi.ico" style="vertical-align:middle"> mixi
feedb7c @ainoya modify README.md
ainoya authored
50 <td> <a href="https://github.com/ufssf">ufssf</a>
9038bf6 @wnadeau README updated for mailchimp hoobajooba
wnadeau authored
51 <tr> <td> <img src="http://static.mailchimp.com/www/downloads/brand-assets/Freddie_Light_Background.png" style="vertical-align:middle" width="16px"> Mailchimp
52 <td> <a href="http://github.com/wnadeau">Winfred Nadeau</a>
3ba53d8 @edy Add Mendeley OAuth support
edy authored
53 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/mendeley.ico" style="vertical-align:middle"> Mendeley
54 <td> <a href="https://github.com/edy-b">Eduard Baun</a>
82eae60 @jzabel Modification to salesforce / stripe ico
jzabel authored
55 <tr> <td> <img src="https://github.com/Datahero/everyauth/raw/express3/media/stripe.ico" style="vertical-align:middle;" width="16px" height="16px"> Stripe
520dffd @jzabel Modification to salesforce / stripe ico
jzabel authored
56 <td> <a href="https://github.com/jzabel">Jeff Zabel</a> from <a href="http://www.datahero.com"> Datahero </a>
050f3e7 @jzabel Modification to salesforce / stripe ico
jzabel authored
57 <tr> <td> <img src="https://github.com/Datahero/everyauth/raw/express3/media/salesforce.ico" style="vertical-align:middle"> Salesforce
9036d36 @jzabel Add salesforce and stripe to readme docs and set credit
jzabel authored
58 <td> <a href="https://github.com/jzabel">Jeff Zabel</a> from <a href="http://www.datahero.com"> Datahero </a>
1f57b6c @bnoguchi Close <tbody> and <table> tags in README
authored
59 </tbody>
d07ffcd @bnoguchi More README markup fixes
authored
60 <tbody id=misc>
2832729 @bnoguchi README table markup fixes
authored
61 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/box.ico" style="vertical-align:middle"> Box.net <td>
cdaf3ac @bnoguchi Re-ordered modules in README
authored
62 <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/openid.ico" style="vertical-align:middle" width="16px" height="16px"> OpenId <td> <a href="https://github.com/rocketlabsdev">RocketLabs Development</a>, <a href="https://github.com/starfishmod">Andrew Mee, <a href="https://github.com/bnoguchi">Brian Noguchi</a>
4d722bb README typo fixes
Marek Obuchowicz authored
63 <tr> <td> LDAP / ActiveDirectory <td> <a href="https://github.com/marek-obuchowicz">Marek Obuchowicz</a> from <a href="https://www.korekontrol.eu/">Korekontrol</a>
19e0d55 add azure acs to readme
woloski authored
64 <tr> <td> Windows Azure Access Control Service (ACS)<td> <a href="https://github.com/darrenzully">Dario Renzulli</a>, <a href="https://github.com/jpgarcia">Juan Pablo Garcia</a>, <a href="https://github.com/woloski">Matias Woloski</a> from <a href="http://blogs.southworks.net/">Southworks</a>
1f57b6c @bnoguchi Close <tbody> and <table> tags in README
authored
65 </tbody>
66 </table>
520dffd @jzabel Modification to salesforce / stripe ico
jzabel authored
67
2912ca1 @bnoguchi Added a README to explore what the API might look like.
authored
68 `everyauth` is:
69
66432cf @bnoguchi Updated README formatting
authored
70 - **Modular** - We have you covered with Facebook and Twitter
16fd71a @bnoguchi Removed hanging semi-colon syntax errors. Started to update README.
authored
71 OAuth logins, basic login/password support, and modules
72 coming soon for beta invitation support and more.
66432cf @bnoguchi Updated README formatting
authored
73 - **Easily Configurable** - everyauth was built with powerful
e68f4d3 @bnoguchi Updated the README. Added comment to oauth.js
authored
74 configuration needs in mind. Configure an authorization strategy
75 in a straightforward, easy-to-read & easy-to-write approach,
76 with as much granularity as you want over the steps and
77 logic of your authorization strategy.
66432cf @bnoguchi Updated README formatting
authored
78 - **Idiomatic** - The syntax for configuring and extending your authorization strategies are
e0ed39b @bnoguchi Replaced multiple success parameter events with one succeed hook. Rep…
authored
79 idiomatic and chainable.
66432cf @bnoguchi Updated README formatting
authored
80
2912ca1 @bnoguchi Added a README to explore what the API might look like.
authored
81
82 ## Installation
83 $ npm install everyauth
84
42c9e83 @bnoguchi Updated the README with a Quick Start section.
authored
85 ## Quick Start
1b8dbfd @bnoguchi Update README with express3 semantics.
authored
86
87 Incorporate everyauth into your express app in just 2 easy steps.
42c9e83 @bnoguchi Updated the README with a Quick Start section.
authored
88
66432cf @bnoguchi Updated README formatting
authored
89 1. **Choose and Configure Auth Strategies** - Find the authentication strategy
42c9e83 @bnoguchi Updated the README with a Quick Start section.
authored
90 you desire in one of the sections below. Follow the configuration
91 instructions.
1b8dbfd @bnoguchi Update README with express3 semantics.
authored
92 2. **Add the Middleware to Express**
2633fb8 @bnoguchi Update README and correct twitter handle
authored
93
1f73588 @bnoguchi Test js syntax highlighting in README
authored
94 ```javascript
95 var everyauth = require('everyauth');
96 // Step 1 code goes here
97
98 // Step 2 code
1b8dbfd @bnoguchi Update README with express3 semantics.
authored
99 var express = require('express');
100 var app = express();
101 app
102 .use(express.bodyParser())
103 .use(express.cookieParser('mr ripley'))
104 .use(express.session())
105 .use(everyauth.middleware(app));
1f73588 @bnoguchi Test js syntax highlighting in README
authored
106 ```
2633fb8 @bnoguchi Update README and correct twitter handle
authored
107
860a673 @bnoguchi Added an example app for developers to use as a reference.
authored
108 ## Example Application
109
9da038c @bnoguchi Updated README typo
authored
110 There is an example application at [./example](https://github.com/bnoguchi/everyauth/tree/master/example)
860a673 @bnoguchi Added an example app for developers to use as a reference.
authored
111
112 To run it:
113
114 $ cd example
115 $ node server.js
116
f99ccc0 @bnoguchi Updated README. Added automatic myHostname detection + assignment to …
authored
117 **Important** - Some OAuth Providers do not allow callbacks to localhost, so you will need to create a `localhost`
860a673 @bnoguchi Added an example app for developers to use as a reference.
authored
118 alias called `local.host`. Make sure you set up your /etc/hosts so that 127.0.0.1 is also
119 associated with 'local.host'. So inside your /etc/hosts file, one of the lines will look like:
120
121 127.0.0.1 localhost local.host
122
123 Then point your browser to [http://local.host:3000](http://local.host:3000)
124
8dc9c41 @bnoguchi Added tests for password module.
authored
125 ## Tests
126
263ef78 @bnoguchi Move common README topics to the top
authored
127 $ npm install everyauth --dev
1f78f5f @bnoguchi Update the README tests section
authored
128
129 Then, update test/creds.js with credentials that the integration tests use to
130 login to each 3rd party service.
131
263ef78 @bnoguchi Move common README topics to the top
authored
132 $ make test
8dc9c41 @bnoguchi Added tests for password module.
authored
133
263ef78 @bnoguchi Move common README topics to the top
authored
134 ## Accessing the User
8dc9c41 @bnoguchi Added tests for password module.
authored
135
263ef78 @bnoguchi Move common README topics to the top
authored
136 If you are using `express` or `connect`, then `everyauth`
137 provides an easy way to access the user as:
138
139 - `req.user` from your app server
140 - `everyauth.user` via the `everyauth` helper accessible from your `express` views.
141 - `user` as a helper accessible from your `express` views
142
19268fb @bnoguchi Add ability to configure a userPkey param, in case you don't use user.id
authored
143 To access the user, configure `everyauth.everymodule.findUserById` and
144 optionally `everyauth.everymodule.userPkey`.
263ef78 @bnoguchi Move common README topics to the top
authored
145 For example, using [mongoose](http://github.com/LearnBoost/mongoose):
146
147 ```javascript
148 everyauth.everymodule.findUserById( function (userId, callback) {
149 User.findById(userId, callback);
150 // callback has the signature, function (err, user) {...}
151 });
152 ```
153
a8c4afc @evdb Allow findUserById to get access to the request if needed
evdb authored
154 If you need access to the request object the function can have three arguments:
155
156 ```javascript
157 everyauth.everymodule.findUserById( function (req, userId, callback) {
158
159 // use the request in some way ...
160
161 // callback has the signature, function (err, user) {...}
162 });
163 ```
164
263ef78 @bnoguchi Move common README topics to the top
authored
165 Once you have configured this method, you now have access to the user object
166 that was fetched anywhere in your server app code as `req.user`. For instance:
167
168 ```javascript
169 var app = require('express').createServer()
170
171 // Configure your app
172
173 app.get('/', function (req, res) {
174 console.log(req.user); // FTW!
175 res.render('home');
176 });
177 ```
178
179 Moreover, you can access the user in your views as `everyauth.user` or as `user`.
180
181 //- Inside ./views/home.jade
182 span.user-id= everyauth.user.name
183 #user-id= user.id
184
19268fb @bnoguchi Add ability to configure a userPkey param, in case you don't use user.id
authored
185 `everyauth` assumes that you store your users with an `id` property. If not --
186 e.g, if you adopt the convention `user.uid` over `user.id` -- then just make
187 sure to configure the `everyauth.everymodule.userPkey` parameter:
188
189 ```javascript
190 everyauth.everymodule.userPkey('uid');
191 ```
192
263ef78 @bnoguchi Move common README topics to the top
authored
193 ## Express Helpers
194
195 If you are using express, everyauth comes with some useful dynamic helpers.
196 To enable them:
197
198 ```javascript
199 var express = require('express')
200 , everyauth = require('everyauth')
201 , app = express.createServer();
202
203 everyauth.helpExpress(app);
204 ```
205
206 Then, from within your views, you will have access to the following helpers methods
207 attached to the helper, `everyauth`:
208
209 - `everyauth.loggedIn`
210 - `everyauth.user` - the User document associated with the session
211 - `everyauth.facebook` - The is equivalent to what is stored at `req.session.auth.facebook`,
212 so you can do things like ...
213 - `everyauth.facebook.user` - returns the user json provided from the OAuth provider.
214 - `everyauth.facebook.accessToken` - returns the access_token provided from the OAuth provider
215 for authorized API calls on behalf of the user.
216 - And you also get this pattern for other modules - e.g., `everyauth.twitter.user`,
217 `everyauth.github.user`, etc.
218
219 You also get access to the view helper
220
221 - `user` - the same as `everyauth.user` above
222
223 As an example of how you would use these, consider the following `./views/user.jade` jade template:
224
225 .user-id
226 .label User Id
227 .value #{user.id}
228 .facebook-id
229 .label User Facebook Id
230 .value #{everyauth.facebook.user.id}
231
232 If you already have an express helper named `user`, then you can configure
233 `everyauth` to use a different helper name to access the user object that
234 everyauth manages. To do so, leverage the `userAlias` option for
235 `everyauth.helpExpress`:
236
237 ```javascript
238 everyauth.helpExpress(app, { userAlias: '__user__' });
239 ```
240
241 Then, you could access the user object in your view with the helper `__user__`
242 instead of the default helper `user`. So you can compare with the default use
243 of helpers given previously, the alternative leveraging userAlias would look like:
244
245 .user-id
246 .label User Id
247 .value #{__user__.id}
248 .facebook-id
249 .label User Facebook Id
250 .value #{everyauth.facebook.user.id}
251
252 `everyauth` also provides convenience methods on the `ServerRequest` instance `req`.
253 From any scope that has access to `req`, you get the following convenience getters and methods:
254
255 - `req.loggedIn` - a Boolean getter that tells you if the request is by a logged in user
256 - `req.user` - the User document associated with the session
0316601 @bnoguchi Fix typo. Closes GH-451
authored
257 - `req.logout()` - clears the session of your auth data
8dc9c41 @bnoguchi Added tests for password module.
authored
258
843d9ec @bnoguchi Added logout information to the README.
authored
259 ## Logging Out
260
261 If you integrate `everyauth` with `connect`, then `everyauth` automatically
262 sets up a `logoutPath` at `GET` `/logout` for your app. It also
263 sets a default handler for your logout route that clears your session
264 of auth information and redirects them to '/'.
265
266 To over-write the logout path:
267
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
268 ```javascript
269 everyauth.everymodule.logoutPath('/bye');
270 ```
843d9ec @bnoguchi Added logout information to the README.
authored
271
272 To over-write the logout redirect path:
273
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
274 ```javascript
275 everyauth.everymodule.logoutRedirectPath('/navigate/to/after/logout');
276 ```
843d9ec @bnoguchi Added logout information to the README.
authored
277
278 To over-write the logout handler:
279
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
280 ```javascript
281 everyauth.everymodule.handleLogout( function (req, res) {
282 // Put you extra logic here
283
284 req.logout(); // The logout method is added for you by everyauth, too
285
286 // And/or put your extra logic here
287
1c6efa9 @pirxpilot Add everymodule.performRedirect configurable method
pirxpilot authored
288 this.redirect(res, this.logoutRedirectPath());
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
289 });
290 ```
843d9ec @bnoguchi Added logout information to the README.
authored
291
d711aab @bnoguchi Clarify custom password login/registration redirect in README
authored
292 ## Custom redirect on password-based login or registration
6d2d8be Add documentation for respondToLoginSucceed and respondToRegistration…
Robert Damphousse authored
293
294 You may want your own callback that decides where to send a user after login or registration. One way of doing this is with the `respondToLoginSucceed` and `respondToRegistrationSucceed` methods. This assumes that you have set a `.redirectTo` property on your `req.session` object:
295
1c6efa9 @pirxpilot Add everymodule.performRedirect configurable method
pirxpilot authored
296 ```javascript
6d2d8be Add documentation for respondToLoginSucceed and respondToRegistration…
Robert Damphousse authored
297 everyauth.password
4e3dfc3 Change "req" to "data"
Robert Damphousse authored
298 .respondToLoginSucceed( function (res, user, data) {
6d2d8be Add documentation for respondToLoginSucceed and respondToRegistration…
Robert Damphousse authored
299 if (user) {
1c6efa9 @pirxpilot Add everymodule.performRedirect configurable method
pirxpilot authored
300 this.redirect(res, data.session.redirectTo)
6d2d8be Add documentation for respondToLoginSucceed and respondToRegistration…
Robert Damphousse authored
301 }
302 })
4e3dfc3 Change "req" to "data"
Robert Damphousse authored
303 .respondToRegistrationSucceed( function (res, user, data) {
1c6efa9 @pirxpilot Add everymodule.performRedirect configurable method
pirxpilot authored
304 this.redirect(res, data.session.redirectTo)
6d2d8be Add documentation for respondToLoginSucceed and respondToRegistration…
Robert Damphousse authored
305 })
306 ```
307
1c6efa9 @pirxpilot Add everymodule.performRedirect configurable method
pirxpilot authored
308 If you are using express and want your redirects to be subject to [express
309 redirect mapping](http://expressjs.com/guide.html#res.redirect\(\)), you can
310 overwrite redirect method employed by everyauth.
311
312 ```javascript
313 everyauth.everymodule
314 .performRedirect( function (res, location) {
315 res.redirect(location, 303);
316 });
317 ```
318
319 A newly defined method will be used by everyauth to perform all redirects.
320
c4a4929 @bnoguchi README formatting
authored
321 # Auth Strategy Instructions
322
39f53ba @bnoguchi More succint headers
authored
323 ## Facebook Connect
2912ca1 @bnoguchi Added a README to explore what the API might look like.
authored
324
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
325 ```javascript
326 var everyauth = require('everyauth')
327 , connect = require('connect');
328
329 everyauth.facebook
330 .appId('YOUR APP ID HERE')
331 .appSecret('YOUR APP SECRET HERE')
89286f8 @bnoguchi Updated the README with instructions for configuring how to handle Fa…
authored
332 .handleAuthCallbackError( function (req, res) {
333 // If a user denies your app, Facebook will redirect the user to
334 // /auth/facebook/callback?error_reason=user_denied&error=access_denied&error_description=The+user+denied+your+request.
335 // This configurable route handler defines how you want to respond to
336 // that.
337 // If you do not configure this, everyauth renders a default fallback
338 // view notifying the user that their authentication failed and why.
339 })
7b06df2 @bnoguchi Corrected findOrCreateUser typo in documentation. Closes GH-14.
authored
340 .findOrCreateUser( function (session, accessToken, accessTokExtra, fbUserMetadata) {
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
341 // find or create user logic goes here
342 })
343 .redirectPath('/');
344
345 var routes = function (app) {
346 // Define your routes here
347 };
348
349 connect(
350 connect.bodyParser()
351 , connect.cookieParser()
352 , connect.session({secret: 'whodunnit'})
353 , everyauth.middleware()
354 , connect.router(routes);
355 ).listen(3000);
356 ```
3f5a806 @bnoguchi Added password module for login/password authentication.
authored
357
e68f4d3 @bnoguchi Updated the README. Added comment to oauth.js
authored
358 You can also configure more parameters (most are set to defaults) via
359 the same chainable API:
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
360
8ca1f5f @christophlsa whitespaces at the end of lines in README removed
christophlsa authored
361 ```javascript
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
362 everyauth.facebook
363 .entryPath('/auth/facebook')
364 .callbackPath('/auth/facebook/callback')
bf57240 @gilad61 Add fields option to facebook (see http:/developers.facebook.com/docs…
gilad61 authored
365 .scope('email') // Defaults to undefined
366 .fields('id,name,email,picture') // Controls the returned fields. Defaults to undefined
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
367 ```
e68f4d3 @bnoguchi Updated the README. Added comment to oauth.js
authored
368
369 If you want to see what the current value of a
370 configured parameter is, you can do so via:
371
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
372 ```javascript
373 everyauth.facebook.scope(); // undefined
bf57240 @gilad61 Add fields option to facebook (see http:/developers.facebook.com/docs…
gilad61 authored
374 everyauth.facebook.fields(); // undefined
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
375 everyauth.facebook.entryPath(); // '/auth/facebook'
376 ```
2dd983d @bnoguchi Added configurable() introspection documentation to the README
authored
377
378 To see all parameters that are configurable, the following will return an
379 object whose parameter name keys map to description values:
380
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
381 ```javascript
382 everyauth.facebook.configurable();
383 ```
66432cf @bnoguchi Updated README formatting
authored
384
2633fb8 @bnoguchi Update README and correct twitter handle
authored
385 ### Dynamic Facebook Connect Scope
46b6dcc @bnoguchi Added documentation to README for dynamic "scope" assignment for Face…
authored
386
387 Facebook provides many different
388 [permissions](http://developers.facebook.com/docs/authentication/permissions/)
389 for which your app can ask your user. This is bundled up in the `scope` query
390 paremter sent with the oauth request to Facebook. While your app may require
391 several different permissions from Facebook, Facebook recommends that you only
392 ask for these permissions incrementally, as you need them. For example, you might
393 want to only ask for the "email" scope upon registration. At the same time, for
394 another user, you may want to ask for "user_status" permissions because they
395 have progressed further along in your application.
396
397 `everyauth` enables you to specify the "scope" dynamically with a second
398 variation of the configurable `scope`. In addition to the first variation
399 that looks like:
400
401 ```javascript
402 everyauth.facebook
403 .scope('email,user_status');
404 ```
405
406 you can have greater dynamic control over "scope" via the second variation of `scope`:
407
408 ```javascript
409 everyauth.facebook
410 .scope( function (req, res) {
411 var session = req.session;
412 switch (session.userPhase) {
413 case 'registration':
414 return 'email';
415 case 'share-media':
416 return 'email,user_status';
417 }
418 });
419
420 ```
421
2633fb8 @bnoguchi Update README and correct twitter handle
authored
422 ### Facebook Mobile OAuth Dialog
19e8ef8 Document how to use facebook oauth dialog via `mobile(true)`
Brian Noguchi authored
423 If you are programming for mobile, you can bring up the facebook mobile OAuth
424 dialog instead of the traditional desktop browser-based one by just adding
425 `mobile(true)` to your configuration as seen here:
426
427 ```javascript
428 everyauth.facebook
429 .mobile(true)
430 .appId('YOUR APP ID HERE')
431 .appSecret('YOUR APP SECRET HERE')
432 // rest of configuration
433 ```
434
39f53ba @bnoguchi More succint headers
authored
435 ## Twitter OAuth
c806176 @bnoguchi Added OAuth module (vs OAuth2 module) and Twitter module.
authored
436
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
437 ```javascript
438 var everyauth = require('everyauth')
439 , connect = require('connect');
440
441 everyauth.twitter
442 .consumerKey('YOUR CONSUMER ID HERE')
443 .consumerSecret('YOUR CONSUMER SECRET HERE')
444 .findOrCreateUser( function (session, accessToken, accessTokenSecret, twitterUserMetadata) {
445 // find or create user logic goes here
446 })
447 .redirectPath('/');
448
449 var routes = function (app) {
450 // Define your routes here
451 };
452
453 connect(
454 connect.bodyParser()
455 , connect.cookieParser()
456 , connect.session({secret: 'whodunnit'})
457 , everyauth.middleware()
458 , connect.router(routes);
459 ).listen(3000);
460 ```
cb2b510 @bnoguchi Updated README to include instructions for what to set your oauth cal…
authored
461
f99ccc0 @bnoguchi Updated README. Added automatic myHostname detection + assignment to …
authored
462 **Important** - Some developers forget to do the following, and it causes them to have issues with `everyauth`.
463 Please make sure to do the following: When you set up your app at http://dev.twitter.com/, make sure that your callback url is set up to
cb2b510 @bnoguchi Updated README to include instructions for what to set your oauth cal…
authored
464 include that path '/auth/twitter/callback/'. In general, when dealing with OAuth or OAuth2 modules
465 provided by `everyauth`, the default callback path is always set up to follow the pattern
466 '/auth/#{moduleName}/callback', so just ensure that you configure your OAuth settings accordingly with
467 the OAuth provider -- in this case, the "Edit Application Settings" section for your app at http://dev.twitter.com.
e7d47e6 @bnoguchi Added documentation for over-riding Twitter's callback URL. Closes GH…
authored
468
469 Alternatively, you can specify the callback url at the application level by configuring `callbackPath` (which
470 has a default configuration of "/auth/twitter/callback"):
471
472 ```javascript
473 everyauth.twitter
474 .consumerKey('YOUR CONSUMER ID HERE')
475 .consumerSecret('YOUR CONSUMER SECRET HERE')
476 .callbackPath('/custom/twitter/callback/path')
477 .findOrCreateUser( function (session, accessToken, accessTokenSecret, twitterUserMetadata) {
478 // find or create user logic goes here
479 })
480 .redirectPath('/');
481 ```
482
483 So if your hostname is `example.com`, then this configuration will over-ride the `dev.twitter.com` callback url configuration.
484 Instead, Twitter will redirect back to `example.com/custom/twitter/callback/path` in the example just given above.
485
486 You can also configure more parameters (most are set to defaults) via
487 the same chainable API:
488
8ca1f5f @christophlsa whitespaces at the end of lines in README removed
christophlsa authored
489 ```javascript
e7d47e6 @bnoguchi Added documentation for over-riding Twitter's callback URL. Closes GH…
authored
490 everyauth.twitter
491 .entryPath('/auth/twitter')
492 .callbackPath('/auth/twitter/callback');
493 ```
494
495 If you want to see what the current value of a
496 configured parameter is, you can do so via:
497
498 ```javascript
499 everyauth.twitter.callbackPath(); // '/auth/twitter/callback'
500 everyauth.twitter.entryPath(); // '/auth/twitter'
501 ```
502
503 To see all parameters that are configurable, the following will return an
504 object whose parameter name keys map to description values:
505
506 ```javascript
507 everyauth.twitter.configurable();
508 ```
e68f4d3 @bnoguchi Updated the README. Added comment to oauth.js
authored
509
39f53ba @bnoguchi More succint headers
authored
510 ## Password Authentication
82ce3e1 @bnoguchi Updated the instructions for the password module in README
authored
511
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
512 ```javascript
513 var everyauth = require('everyauth')
514 , connect = require('connect');
515
516 everyauth.password
46a6e09 @bnoguchi Improved API for registration section of password module. Handling of…
authored
517 .getLoginPath('/login') // Uri path to the login page
518 .postLoginPath('/login') // Uri path that your login form POSTs to
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
519 .loginView('a string of html; OR the name of the jade/etc-view-engine view')
520 .authenticate( function (login, password) {
5097b2d @bnoguchi Improved password.authenticate API to use more intuitive return values.
authored
521 // Either, we return a user or an array of errors if doing sync auth.
522 // Or, we return a Promise that can fulfill to promise.fulfill(user) or promise.fulfill(errors)
46a6e09 @bnoguchi Improved API for registration section of password module. Handling of…
authored
523 // `errors` is an array of error message strings
524 //
525 // e.g.,
526 // Example 1 - Sync Example
527 // if (usersByLogin[login] && usersByLogin[login].password === password) {
5097b2d @bnoguchi Improved password.authenticate API to use more intuitive return values.
authored
528 // return usersByLogin[login];
46a6e09 @bnoguchi Improved API for registration section of password module. Handling of…
authored
529 // } else {
5097b2d @bnoguchi Improved password.authenticate API to use more intuitive return values.
authored
530 // return ['Login failed'];
46a6e09 @bnoguchi Improved API for registration section of password module. Handling of…
authored
531 // }
532 //
533 // Example 2 - Async Example
534 // var promise = this.Promise()
535 // YourUserModel.find({ login: login}, function (err, user) {
5097b2d @bnoguchi Improved password.authenticate API to use more intuitive return values.
authored
536 // if (err) return promise.fulfill([err]);
537 // promise.fulfill(user);
46a6e09 @bnoguchi Improved API for registration section of password module. Handling of…
authored
538 // }
539 // return promise;
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
540 })
46a6e09 @bnoguchi Improved API for registration section of password module. Handling of…
authored
541 .loginSuccessRedirect('/') // Where to redirect to after a login
542
543 // If login fails, we render the errors via the login view template,
544 // so just make sure your loginView() template incorporates an `errors` local.
545 // See './example/views/login.jade'
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
546
46a6e09 @bnoguchi Improved API for registration section of password module. Handling of…
authored
547 .getRegisterPath('/register') // Uri path to the registration page
548 .postRegisterPath('/register') // The Uri path that your registration form POSTs to
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
549 .registerView('a string of html; OR the name of the jade/etc-view-engine view')
46a6e09 @bnoguchi Improved API for registration section of password module. Handling of…
authored
550 .validateRegistration( function (newUserAttributes) {
551 // Validate the registration input
552 // Return undefined, null, or [] if validation succeeds
553 // Return an array of error messages (or Promise promising this array)
554 // if validation fails
555 //
556 // e.g., assuming you define validate with the following signature
557 // var errors = validate(login, password, extraParams);
558 // return errors;
559 //
560 // The `errors` you return show up as an `errors` local in your jade template
561 })
562 .registerUser( function (newUserAttributes) {
3a3e59b @bnoguchi Updated the README
authored
563 // This step is only executed if we pass the validateRegistration step without
564 // any errors.
9472fe2 @bnoguchi Accounted for possible uniqueness error appearing in the registerUser…
authored
565 //
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
566 // Returns a user (or a Promise that promises a user) after adding it to
463e1de @bnoguchi Correction to README section on registerUser
authored
567 // some user store.
9472fe2 @bnoguchi Accounted for possible uniqueness error appearing in the registerUser…
authored
568 //
569 // As an edge case, sometimes your database may make you aware of violation
570 // of the unique login index, so if this error is sent back in an async
571 // callback, then you can just return that error as a single element array
572 // containing just that error message, and everyauth will automatically handle
573 // that as a failed registration. Again, you will have access to this error via
574 // the `errors` local in your register view jade template.
575 // e.g.,
576 // var promise = this.Promise();
577 // User.create(newUserAttributes, function (err, user) {
578 // if (err) return promise.fulfill([err]);
579 // promise.fulfill(user);
580 // });
581 // return promise;
463e1de @bnoguchi Correction to README section on registerUser
authored
582 //
583 // Note: Index and db-driven validations are the only validations that occur
584 // here; all other validations occur in the `validateRegistration` step documented above.
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
585 })
5097b2d @bnoguchi Improved password.authenticate API to use more intuitive return values.
authored
586 .registerSuccessRedirect('/'); // Where to redirect to after a successful registration
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
587
588 var routes = function (app) {
589 // Define your routes here
590 };
591
592 connect(
593 connect.bodyParser()
594 , connect.cookieParser()
595 , connect.session({secret: 'whodunnit'})
596 , everyauth.middleware()
597 , connect.router(routes);
598 ).listen(3000);
599 ```
1eb3bb6 @bnoguchi Added Author and License information to README
authored
600
8a98435 @bnoguchi ea.password.loginName and ea.password.passwordName become ea.password…
authored
601 You can also configure more parameters (most are set to defaults) via
602 the same chainable API:
603
8ca1f5f @christophlsa whitespaces at the end of lines in README removed
christophlsa authored
604 ```javascript
8a98435 @bnoguchi ea.password.loginName and ea.password.passwordName become ea.password…
authored
605 everyauth.password
606 .loginFormFieldName('login') // Defaults to 'login'
607 .passwordFormFieldName('password') // Defaults to 'password'
f4e0c66 @bnoguchi Password module changes: (1) Can now change layout for login and regi…
authored
608 .loginLayout('custom_login_layout') // Only with `express`
609 .registerLayout('custom reg_layout') // Only with `express`
610 .loginLocals(fn); // See Recipe 3 below
8a98435 @bnoguchi ea.password.loginName and ea.password.passwordName become ea.password…
authored
611 ```
612
613 If you want to see what the current value of a
614 configured parameter is, you can do so via:
615
616 ```javascript
617 everyauth.password.loginFormFieldName(); // 'login'
618 everyauth.password.passwordFormFieldName(); // 'password'
619 ```
620
621 To see all parameters that are configurable, the following will return an
622 object whose parameter name keys map to description values:
623
624 ```javascript
625 everyauth.password.configurable();
626 ```
627
f9ec7fd @bnoguchi Fix copy
authored
628 ### Password Recipe 1: Extra registration data
fb81710 @bnoguchi Real version bump to v0.2.0
authored
629
46a6e09 @bnoguchi Improved API for registration section of password module. Handling of…
authored
630 Sometimes your registration will ask for more information from the user besides the login and password.
631
632 For this particular scenario, you can configure the optional step, `extractExtraRegistrationParams`.
633
634 ```javascript
635 everyauth.password.extractExtraRegistrationParams( function (req) {
636 return {
637 phone: req.body.phone
638 , name: {
639 first: req.body.first_name
640 , last: req.body.last_name
641 }
642 };
643 });
644 ```
645
4fc029f @bnoguchi Update README with more details about password extra registration params
authored
646 Then, you will have access to this data from within your configured
647 `validateRegistration` and `registerUser`:
648
649 ```javascript
650 everyauth.password
651 .validateRegistration( function (newUserAttributes) {
652 var phone = newUserAttributes.phone
653 , firstName = newUserAttributes.name.first
654 , lastName = newUserAttributes.name.last;
655 })
656 .registerUser( function (newUserAttributes) {
657 var phone = newUserAttributes.phone
658 , firstName = newUserAttributes.name.first
659 , lastName = newUserAttributes.name.last;
660 });
661 ```
662
263343d @bnoguchi Added out-of-the-box login types (login, email, and phone) to provide…
authored
663 ### Password Recipe 2: Logging in with email or phone number
664
665 By default, `everyauth` uses the field and user key name `login` during the
666 registration and login process.
667
668 Sometimes, you want to use `email` or `phone` instead of `login`. Moreover,
669 you also want to validate `email` and `phone` fields upon registration.
670
671 `everyauth` provides an easy way to do this:
672
673 ```javascript
674 everyauth.password.loginWith('email');
675
676 // OR
677
678 everyauth.password.loginWith('phone');
679 ```
680
681 With simple login configuration like this, you get email (or phone) validation
682 in addition to renaming of the form field and user key corresponding to what
683 otherwise would typically be referred to as 'login'.
684
f4e0c66 @bnoguchi Password module changes: (1) Can now change layout for login and regi…
authored
685 ### Password Recipe 3: Adding additional view local variables to login and registration views
686
687 If you are using `express`, you are able to pass variables from your app
688 context to your view context via local variables. `everyauth` provides
689 several convenience local vars for your views, but sometimes you will want
690 to augment this set of local vars with additional locals.
691
692 So `everyauth` also provides a mechanism for you to do so via the following
693 configurables:
694
695 ```javascript
696 everyauth.password.loginLocals(...);
697 everyauth.password.registerLocals(...);
698 ```
699
700 `loginLocals` and `registerLocals` configuration have symmetrical APIs, so I
701 will only cover `loginLocals` here to illustrate how to use both.
702
703 You can configure this parameter in one of *3* ways. Why 3? Because there are 3 types of ways that you can retrieve your locals.
704
705 1. Static local vars that never change values:
2e11c7e @bnoguchi README formatting - bullets.
authored
706
2c83ecd @bnoguchi README formatting
authored
707 ```javascript
708 everyauth.password.loginLocals({
709 title: 'Login'
710 });
711 ```
f4e0c66 @bnoguchi Password module changes: (1) Can now change layout for login and regi…
authored
712 2. Dynamic synchronous local vars that depend on the incoming request, but whose values are retrieved synchronously
713
585a3f9 @bnoguchi README formatting
authored
714 ```javascript
715 everyauth.password.loginLocals( function (req, res) {
716 var sess = req.session;
717 return {
718 isReturning: sess.isReturning
719 };
720 });
721 ```
f4e0c66 @bnoguchi Password module changes: (1) Can now change layout for login and regi…
authored
722 3. Dynamic asynchronous local vars
723
585a3f9 @bnoguchi README formatting
authored
724 ```javascript
725 everyauth.password.loginLocals( function (req, res, done) {
726 asyncCall( function ( err, data) {
727 if (err) return done(err);
728 done(null, {
729 title: il8n.titleInLanguage('Login Page', il8n.language(data.geo))
730 });
731 });
f4e0c66 @bnoguchi Password module changes: (1) Can now change layout for login and regi…
authored
732 });
585a3f9 @bnoguchi README formatting
authored
733 ```
f4e0c66 @bnoguchi Password module changes: (1) Can now change layout for login and regi…
authored
734
4c938d6 @bnoguchi Added documentation for custom validateRegistration for the password …
authored
735 ### Password Recipe 4: Customize Your Registration Validation
736
737 By default, `everyauth.password` automatically
738
739 - validates that the login (or email or phone, depending on what you authenticate with -- see Password Recipe 2) is present in the login http request,
740 - validates that the password is present
741 - validates that an email login is a correctly formatted email
742 - validates that a phone login is a valid phone number
743
744 If any of these validations fail, then the appropriate errors are generated and accessible to you in your view via the `errors` view local variable.
745
746 If you want to add additional validations beyond this, you can do so by configuring the step, `validateRegistration`:
747
748 ```javascript
749 everyauth.password
750 .validateRegistration( function (newUserAttributes, baseErrors) {
751 // Here, newUserAttributes is the hash of parameters extracted from the incoming request.
752 // baseErrors is the array of errors generated by the default automatic validation outlined above
753 // in this same recipe.
754
755 // First, validate your errors. Here, validateUser is a made up function
756 var moreErrors = validateUser( newUserAttributes );
757 if (moreErrors.length) baseErrors.push.apply(baseErrors, moreErrors);
758
759 // Return the array of errors, so your view has access to them.
760 return baseErrors;
761 });
762 ```
763
f4e3ffc @bnoguchi Add password hashing recipe
authored
764 ### Password Recipe 5: Password Hashing
765
766 By default, everyauth is agnostic about how you decide to store your users and
767 therefore passwords. However, one should *always* use password hashing and
768 salting for security.
769
770 Here's an example of how to incorporate password hashing into everyauth using
771 bcrypt hashing. The idea is to store a salt and hash value inside your user object
772 instead of the password. The hash value is generated from the password (sent with a
773 registration or login request) and unique salt per user, using the bcrypt algorithm.
774
775 ```javascript
776 // Make sure to `npm install bcrypt`
777 var bcrypt = require('bcrypt');
778
779 everyauth.password
780 .registerUser( function (newUserAttrs) {
781 var promise = this.Promise()
782 , password = newUserAttrs.password;
783
784 delete newUserAttrs[password]; // Don't store password
785 newUserAttrs.salt = bcrypt.genSaltSync(10);
786 newUserAttrs.hash = bcrypt.hashSync(password, salt);
787
788 // Create a new user in your data store
789 createUser( newUserAttrs, function (err, createdUser) {
790 if (err) return promise.fail(err);
791 return promise.fulfill(createdUser);
792 });
793
794 return promise;
795 })
796 .authenticate( function (login, password) {
797 var promise
798 , errors = [];
799 if (!login) errors.push('Missing login.');
800 if (!password) errors.push('Missing password.');
801 if (errors.length) return errors;
802
803 promise = this.Promise();
804
805 // findUser passes an error or user to a callback after finding the
806 // user by login
807 findUser( login, function (err, user) {
808 if (err) {
809 errors.push(err.message || err);
810 return promise.fulfill(errors);
811 }
812 if (!user) {
813 errors.push('User with login ' + login + ' does not exist.');
814 return promise.fulfill(errors);
815 }
816 bcrypt.compare(password, user.hash, function (err, didSucceed) {
817 if (err) {
818 return promise.fail(err);
819 errors.push('Wrong password.');
820 return promise.fulfill(errors);
821 }
822 if (didSucceed) return promise.fulfill(user);
823 errors.push('Wrong password.');
824 return promise.fulfill(errors);
825 });
826 });
827
828 return promise;
829 })
830 ```
831
2633fb8 @bnoguchi Update README and correct twitter handle
authored
832 ## Other Modules
833
39f53ba @bnoguchi More succint headers
authored
834 ### GitHub OAuth
a55bb7a @bnoguchi Updated README to include information about how to configure auth for…
authored
835
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
836 ```javascript
837 var everyauth = require('everyauth')
838 , connect = require('connect');
839
840 everyauth.github
841 .appId('YOUR CLIENT ID HERE')
842 .appSecret('YOUR CLIENT SECRET HERE')
7b06df2 @bnoguchi Corrected findOrCreateUser typo in documentation. Closes GH-14.
authored
843 .findOrCreateUser( function (session, accessToken, , accessTokenExtra, githubUserMetadata) {
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
844 // find or create user logic goes here
845 })
846 .redirectPath('/');
847
848 var routes = function (app) {
849 // Define your routes here
850 };
851
852 connect(
853 connect.bodyParser()
854 , connect.cookieParser()
855 , connect.session({secret: 'whodunnit'})
856 , everyauth.middleware()
857 , connect.router(routes);
858 ).listen(3000);
859 ```
a55bb7a @bnoguchi Updated README to include information about how to configure auth for…
authored
860
861 You can also configure more parameters (most are set to defaults) via
862 the same chainable API:
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
863
8ca1f5f @christophlsa whitespaces at the end of lines in README removed
christophlsa authored
864 ```javascript
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
865 everyauth.github
866 .entryPath('/auth/github')
867 .callbackPath('/auth/github/callback')
868 .scope('repo'); // Defaults to undefined
869 // Can be set to a combination of: 'user', 'public_repo', 'repo', 'gist'
870 // For more details, see http://develop.github.com/p/oauth.html
871 ```
a55bb7a @bnoguchi Updated README to include information about how to configure auth for…
authored
872
873 If you want to see what the current value of a
874 configured parameter is, you can do so via:
875
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
876 ```javascript
877 everyauth.github.scope(); // undefined
878 everyauth.github.entryPath(); // '/auth/github'
879 ```
a55bb7a @bnoguchi Updated README to include information about how to configure auth for…
authored
880
881 To see all parameters that are configurable, the following will return an
882 object whose parameter name keys map to description values:
883
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
884 ```javascript
885 everyauth.github.configurable();
886 ```
a55bb7a @bnoguchi Updated README to include information about how to configure auth for…
authored
887
39f53ba @bnoguchi More succint headers
authored
888 ### Instagram OAuth
41df403 @bnoguchi Updated README with instructions for Instagram module.
authored
889
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
890 ```javascript
891 var everyauth = require('everyauth')
892 , connect = require('connect');
893
894 everyauth.instagram
895 .appId('YOUR CLIENT ID HERE')
896 .appSecret('YOUR CLIENT SECRET HERE')
7b06df2 @bnoguchi Corrected findOrCreateUser typo in documentation. Closes GH-14.
authored
897 .findOrCreateUser( function (session, accessToken, accessTokenExtra, instagramUserMetadata) {
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
898 // find or create user logic goes here
899 })
900 .redirectPath('/');
901
902 var routes = function (app) {
903 // Define your routes here
904 };
905
906 connect(
907 connect.bodyParser()
908 , connect.cookieParser()
909 , connect.session({secret: 'whodunnit'})
910 , everyauth.middleware()
911 , connect.router(routes);
912 ).listen(3000);
913 ```
41df403 @bnoguchi Updated README with instructions for Instagram module.
authored
914
915 You can also configure more parameters (most are set to defaults) via
916 the same chainable API:
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
917
8ca1f5f @christophlsa whitespaces at the end of lines in README removed
christophlsa authored
918 ```javascript
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
919 everyauth.instagram
920 .entryPath('/auth/instagram')
921 .callbackPath('/auth/instagram/callback')
922 .scope('basic') // Defaults to 'basic'
923 // Can be set to a combination of: 'basic', 'comments', 'relationships', 'likes'
924 // For more details, see http://instagram.com/developer/auth/#scope
925 .display(undefined); // Defaults to undefined; Set to 'touch' to see a mobile optimized version
926 // of the instagram auth page
927 ```
41df403 @bnoguchi Updated README with instructions for Instagram module.
authored
928
929 If you want to see what the current value of a
930 configured parameter is, you can do so via:
931
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
932 ```javascript
933 everyauth.instagram.callbackPath(); // '/auth/instagram/callback'
934 everyauth.instagram.entryPath(); // '/auth/instagram'
935 ```
41df403 @bnoguchi Updated README with instructions for Instagram module.
authored
936
937 To see all parameters that are configurable, the following will return an
938 object whose parameter name keys map to description values:
939
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
940 ```javascript
941 everyauth.instagram.configurable();
942 ```
41df403 @bnoguchi Updated README with instructions for Instagram module.
authored
943
39f53ba @bnoguchi More succint headers
authored
944 ### Foursquare OAuth
30712de @bnoguchi Added foursquare module and documentation.
authored
945
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
946 ```javascript
947 var everyauth = require('everyauth')
948 , connect = require('connect');
949
950 everyauth.foursquare
951 .appId('YOUR CLIENT ID HERE')
952 .appSecret('YOUR CLIENT SECRET HERE')
7b06df2 @bnoguchi Corrected findOrCreateUser typo in documentation. Closes GH-14.
authored
953 .findOrCreateUser( function (session, accessToken, accessTokenExtra, foursquareUserMetadata) {
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
954 // find or create user logic goes here
955 })
956 .redirectPath('/');
957
958 var routes = function (app) {
959 // Define your routes here
960 };
961
962 connect(
963 connect.bodyParser()
964 , connect.cookieParser()
965 , connect.session({secret: 'whodunnit'})
966 , everyauth.middleware()
967 , connect.router(routes);
968 ).listen(3000);
969 ```
30712de @bnoguchi Added foursquare module and documentation.
authored
970
971 You can also configure more parameters (most are set to defaults) via
972 the same chainable API:
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
973
8ca1f5f @christophlsa whitespaces at the end of lines in README removed
christophlsa authored
974 ```javascript
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
975 everyauth.foursquare
976 .entryPath('/auth/foursquare')
977 .callbackPath('/auth/foursquare/callback');
978 ```
30712de @bnoguchi Added foursquare module and documentation.
authored
979
980 If you want to see what the current value of a
981 configured parameter is, you can do so via:
982
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
983 ```javascript
984 everyauth.foursquare.callbackPath(); // '/auth/foursquare/callback'
985 everyauth.foursquare.entryPath(); // '/auth/foursquare'
986 ```
30712de @bnoguchi Added foursquare module and documentation.
authored
987
988 To see all parameters that are configurable, the following will return an
989 object whose parameter name keys map to description values:
990
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
991 ```javascript
992 everyauth.foursquare.configurable();
993 ```
30712de @bnoguchi Added foursquare module and documentation.
authored
994
39f53ba @bnoguchi More succint headers
authored
995 ### LinkedIn OAuth
098ed70 @bnoguchi Added documentation for linkedin auth module.
authored
996
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
997 ```javascript
998 var everyauth = require('everyauth')
999 , connect = require('connect');
1000
1001 everyauth.linkedin
1002 .consumerKey('YOUR CONSUMER ID HERE')
1003 .consumerSecret('YOUR CONSUMER SECRET HERE')
1004 .findOrCreateUser( function (session, accessToken, accessTokenSecret, linkedinUserMetadata) {
1005 // find or create user logic goes here
1006 })
1007 .redirectPath('/');
1008
1009 var routes = function (app) {
1010 // Define your routes here
1011 };
1012
1013 connect(
1014 connect.bodyParser()
1015 , connect.cookieParser()
1016 , connect.session({secret: 'whodunnit'})
1017 , everyauth.middleware()
1018 , connect.router(routes);
1019 ).listen(3000);
1020 ```
098ed70 @bnoguchi Added documentation for linkedin auth module.
authored
1021
1022 You can also configure more parameters (most are set to defaults) via
1023 the same chainable API:
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
1024
8ca1f5f @christophlsa whitespaces at the end of lines in README removed
christophlsa authored
1025 ```javascript
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
1026 everyauth.linkedin
1027 .entryPath('/auth/linkedin')
1028 .callbackPath('/auth/linkedin/callback');
1029 ```
098ed70 @bnoguchi Added documentation for linkedin auth module.
authored
1030
1031 If you want to see what the current value of a
1032 configured parameter is, you can do so via:
1033
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
1034 ```javascript
1035 everyauth.linkedin.callbackPath(); // '/auth/linkedin/callback'
1036 everyauth.linkedin.entryPath(); // '/auth/linkedin'
1037 ```
098ed70 @bnoguchi Added documentation for linkedin auth module.
authored
1038
1039 To see all parameters that are configurable, the following will return an
1040 object whose parameter name keys map to description values:
1041
2ab9f4f @bnoguchi Converted README to use JS syntax highlighting.
authored
1042 ```javascript
1043 everyauth.linkedin.configurable();
1044 ```
098ed70 @bnoguchi Added documentation for linkedin auth module.
authored
1045
39f53ba @bnoguchi More succint headers
authored
1046 ### Google OAuth2
4c9bd57 @bnoguchi Updated README for google module.
authored
1047
1048 ```javascript
1049 var everyauth = require('everyauth')
1050 , connect = require('connect');
1051
1052 everyauth.google
1053 .appId('YOUR CLIENT ID HERE')
1054 .appSecret('YOUR CLIENT SECRET HERE')
1055 .scope('https://www.google.com/m8/feeds') // What you want access to
1056 .handleAuthCallbackError( function (req, res) {
1057 // If a user denies your app, Google will redirect the user to
1058 // /auth/facebook/callback?error=access_denied
1059 // This configurable route handler defines how you want to respond to
1060 // that.
1061 // If you do not configure this, everyauth renders a default fallback
1062 // view notifying the user that their authentication failed and why.
1063 })
081384f @bnoguchi Fixed typo in README
authored
1064 .findOrCreateUser( function (session, accessToken, accessTokenExtra, googleUserMetadata) {
4c9bd57 @bnoguchi Updated README for google module.
authored
1065 // find or create user logic goes here
1066 // Return a user or Promise that promises a user
1067 // Promises are created via
1068 // var promise = this.Promise();
1069 })
1070 .redirectPath('/');
1071
1072 var routes = function (app) {
1073 // Define your routes here
1074 };
1075
1076 connect(
1077 connect.bodyParser()
1078 , connect.cookieParser()
1079 , connect.session({secret: 'whodunnit'})
1080 , everyauth.middleware()
1081 , connect.router(routes);
1082 ).listen(3000);
1083 ```
1084
1085 You can also configure more parameters (most are set to defaults) via
1086 the same chainable API:
1087
8ca1f5f @christophlsa whitespaces at the end of lines in README removed
christophlsa authored
1088 ```javascript
4c9bd57 @bnoguchi Updated README for google module.
authored
1089 everyauth.google
1090 .entryPath('/auth/google')
1091 .callbackPath('/auth/google/callback');
1092 ```
1093
1094 If you want to see what the current value of a
1095 configured parameter is, you can do so via:
1096
1097 ```javascript
1098 everyauth.google.scope(); // undefined
1099 everyauth.google.entryPath(); // '/auth/google'
1100 ```
1101
1102 To see all parameters that are configurable, the following will return an
1103 object whose parameter name keys map to description values:
1104
1105 ```javascript
1106 everyauth.google.configurable();
1107 ```
1108
39f53ba @bnoguchi More succint headers
authored
1109 ### Gowalla OAuth2
b7a8ce2 @bnoguchi Added andykram to Credits for gowalla module in README. Updated READM…
authored
1110
1111 ```javascript
1112 var everyauth = require('everyauth')
1113 , connect = require('connect');
1114
1115 everyauth.gowalla
1116 .appId('YOUR CLIENT ID HERE')
1117 .appSecret('YOUR CLIENT SECRET HERE')
1118 .handleAuthCallbackError( function (req, res) {
1119 // TODO - Update this documentation
1120 // This configurable route handler defines how you want to respond to
1121 // a response from Gowalla that something went wrong during the oauth2 process.
1122 // If you do not configure this, everyauth renders a default fallback
1123 // view notifying the user that their authentication failed and why.
1124 })
1125 .findOrCreateUser( function (session, accessToken, accessTokenExtra, gowallaUserMetadata) {
1126 // find or create user logic goes here
1127 // Return a user or Promise that promises a user
1128 // Promises are created via
1129 // var promise = this.Promise();
1130 })
1131 .redirectPath('/');
1132
1133 var routes = function (app) {
1134 // Define your routes here
1135 };
1136
1137 connect(
1138 connect.bodyParser()
1139 , connect.cookieParser()
1140 , connect.session({secret: 'whodunnit'})
1141 , everyauth.middleware()
1142 , connect.router(routes);
1143 ).listen(3000);
1144 ```
1145
1146 You can also configure more parameters (most are set to defaults) via
1147 the same chainable API:
1148
8ca1f5f @christophlsa whitespaces at the end of lines in README removed
christophlsa authored
1149 ```javascript
b7a8ce2 @bnoguchi Added andykram to Credits for gowalla module in README. Updated READM…
authored
1150 everyauth.gowalla
1151 .entryPath('/auth/gowalla')
1152 .callbackPath('/auth/gowalla/callback');
1153 ```
1154
1155 If you want to see what the current value of a
1156 configured parameter is, you can do so via:
1157
1158 ```javascript
1159 everyauth.gowalla.scope(); // undefined
1160 everyauth.gowalla.entryPath(); // '/auth/gowalla'
1161 ```
1162
1163 To see all parameters that are configurable, the following will return an
1164 object whose parameter name keys map to description values:
1165
1166 ```javascript
1167 everyauth.gowalla.configurable();
1168 ```
1169
39f53ba @bnoguchi More succint headers
authored
1170 ### 37signals (Basecamp, Highrise, Backpack, Campfire) OAuth2
cd2208a @bnoguchi README instructions for 37signals.
authored
1171
1172 First, register an app at [integrate.37signals.com](https://integrate.37signals.com).
1173
1174 ```javascript
1175 var everyauth = require('everyauth')
1176 , connect = require('connect');
1177
1178 everyauth['37signals']
1179 .appId('YOUR CLIENT ID HERE')
1180 .appSecret('YOUR CLIENT SECRET HERE')
1181 .handleAuthCallbackError( function (req, res) {
1182 // TODO - Update this documentation
1183 // This configurable route handler defines how you want to respond to
1184 // a response from 37signals that something went wrong during the oauth2 process.
1185 // If you do not configure this, everyauth renders a default fallback
1186 // view notifying the user that their authentication failed and why.
1187 })
1188 .findOrCreateUser( function (session, accessToken, accessTokenExtra, _37signalsUserMetadata) {
1189 // find or create user logic goes here
1190 // Return a user or Promise that promises a user
1191 // Promises are created via
1192 // var promise = this.Promise();
1193 })
1194 .redirectPath('/');
1195
1196 var routes = function (app) {
1197 // Define your routes here
1198 };
1199
1200 connect(
1201 connect.bodyParser()
1202 , connect.cookieParser()
1203 , connect.session({secret: 'whodunnit'})
1204 , everyauth.middleware()
1205 , connect.router(routes);
1206 ).listen(3000);
1207 ```
1208
1209 You can also configure more parameters (most are set to defaults) via
1210 the same chainable API:
1211
8ca1f5f @christophlsa whitespaces at the end of lines in README removed
christophlsa authored
1212 ```javascript
cd2208a @bnoguchi README instructions for 37signals.
authored
1213 everyauth['37signals']
1214 .entryPath('/auth/37signals')
1215 .callbackPath('/auth/37signals/callback');
1216 ```
1217
1218 If you want to see what the current value of a
1219 configured parameter is, you can do so via:
1220
1221 ```javascript
1222 everyauth['37signals'].entryPath(); // '/auth/37signals'
1223 ```
1224
1225 To see all parameters that are configurable, the following will return an
1226 object whose parameter name keys map to description values:
1227
1228 ```javascript
1229 everyauth['37signals'].configurable();
1230 ```
1231
39f53ba @bnoguchi More succint headers
authored
1232 ### AngelList OAuth2
24a3cde @bnoguchi Added AngelList instructions to the README
authored
1233
1234 First, register an app [on AngelList](http://angel.co/api/oauth/clients).
1235
1236 ```javascript
1237 var everyauth = require('everyauth')
1238 , connect = require('connect');
1239
1240 everyauth.angellist
1241 .appId('YOUR CLIENT ID HERE')
1242 .appSecret('YOUR TOKEN HERE')
1243 .findOrCreateUser( function (session, accessToken, accessTokenExtra, angelListUserMetadata) {
1244 // find or create user logic goes here
1245 // Return a user or Promise that promises a user
1246 // Promises are created via
1247 // var promise = this.Promise();
1248 })
1249 .redirectPath('/');
1250
1251 var routes = function (app) {
1252 // Define your routes here
1253 };
1254
1255 connect(
1256 connect.bodyParser()
1257 , connect.cookieParser()
1258 , connect.session({secret: 'whodunnit'})
1259 , everyauth.middleware()
1260 , connect.router(routes);
1261 ).listen(3000);
1262 ```
1263
1264 You can also configure more parameters (most are set to defaults) via
1265 the same chainable API:
1266
8ca1f5f @christophlsa whitespaces at the end of lines in README removed
christophlsa authored
1267 ```javascript
24a3cde @bnoguchi Added AngelList instructions to the README
authored
1268 everyauth.angellist
1269 .entryPath('/auth/angellist')
1270 .callbackPath('/auth/angellist/callback');
1271 ```
1272
1273 If you want to see what the current value of a
1274 configured parameter is, you can do so via:
1275
1276 ```javascript
1277 everyauth.angellist.entryPath(); // '/auth/angellist'
1278 ```
1279
1280 To see all parameters that are configurable, the following will return an
1281 object whose parameter name keys map to description values:
1282
1283 ```javascript
1284 everyauth.angellist.configurable();
1285 ```
1286
39f53ba @bnoguchi More succint headers
authored
1287 ### Dwolla OAuth2
08a911e @nanek updated README.md for dwolla module
nanek authored
1288
1289 First, register an app [on Dwolla](http://www.dwolla.com/developers).
1290
1291 ```javascript
1292 var everyauth = require('everyauth')
1293 , connect = require('connect');
1294
1295 everyauth.dwolla
1296 .appId('YOUR CLIENT ID HERE')
1297 .appSecret('YOUR TOKEN HERE')
1298 .scope('accountinfofull')
1299 .findOrCreateUser( function (session, accessToken, accessTokenExtra, dwollaUserMetadata) {
1300 // find or create user logic goes here
1301 // Return a user or Promise that promises a user
1302 // Promises are created via
1303 // var promise = this.Promise();
1304 })
1305 .redirectPath('/');
1306
1307 var routes = function (app) {
1308 // Define your routes here
1309 };
d06187e @srod Updated Skyrock docs
srod authored
1310 ```
80170eb @srod Added Skyrock docs
srod authored
1311
39f53ba @bnoguchi More succint headers
authored
1312 ### Skyrock OAuth
80170eb @srod Added Skyrock docs
srod authored
1313
1314 First, register an app [on Skyrock](http://www.skyrock.com/developer/).
1315
1316 ```javascript
1317 var everyauth = require('everyauth')
1318 , connect = require('connect');
1319
1320 everyauth.skyrock
14449a9 @srod Updated Skyrock docs
srod authored
1321 .consumerKey('YOUR CONSUMER KEY HERE')
1322 .consumerSecret('YOUR CONSUMER SECRET HERE')
80170eb @srod Added Skyrock docs
srod authored
1323 .findOrCreateUser( function (session, accessToken, accessTokenExtra, skyrockUserMetadata) {
1324 // find or create user logic goes here
08a911e @nanek updated README.md for dwolla module
nanek authored
1325 // Return a user or Promise that promises a user
1326 // Promises are created via
1327 // var promise = this.Promise();
1328 })
1329 .redirectPath('/');
1330
1331 var routes = function (app) {
1332 // Define your routes here
1333 };
1334
1335 connect(
1336 connect.bodyParser()
1337 , connect.cookieParser()
1338 , connect.session({secret: 'whodunnit'})
1339 , everyauth.middleware()
1340 , connect.router(routes);
1341 ).listen(3000);
e92808c @meritt Fix readme
meritt authored
1342 ```
08a911e @nanek updated README.md for dwolla module
nanek authored
1343
39f53ba @bnoguchi More succint headers
authored
1344 ### VKontakte OAuth2
563248d @meritt Added readme for vkontakte module
meritt authored
1345
1346 First, register an app [on VKontakte](http://vk.com/editapp?act=create&site=1).
1347
1348 ```javascript
1349 var everyauth = require('everyauth')
1350 , connect = require('connect');
1351
1352 everyauth.vkontakte
1353 .appId('YOUR APP ID HERE')
1354 .appSecret('YOUR TOKEN HERE')
1355 .scope('photo')
1356 .findOrCreateUser( function (session, accessToken, accessTokenExtra, vkUserMetadata) {
1357 // find or create user logic goes here
1358 // Return a user or Promise that promises a user
1359 // Promises are created via
1360 // var promise = this.Promise();
1361 })
1362 .redirectPath('/');
1363
1364 var routes = function (app) {
1365 // Define your routes here
1366 };
1367
1368 connect(
1369 connect.bodyParser()
1370 , connect.cookieParser()
1371 , connect.session({secret: 'whodunnit'})
1372 , everyauth.middleware()
f658742 @vredniy Fix vkontakte example (README.md)
vredniy authored
1373 , connect.router(routes)
563248d @meritt Added readme for vkontakte module
meritt authored
1374 ).listen(3000);
e92808c @meritt Fix readme
meritt authored
1375 ```
563248d @meritt Added readme for vkontakte module
meritt authored
1376
d0d1fd6 @bnoguchi Merge branch 'master' of https://github.com/biggora/everyauth into bi…
authored
1377 ### Mail.ru OAuth2
1378
1379 First, register an app [on mail.ru](http://api.mail.ru/apps/my/add/).
1380
1381 ```javascript
1382 var everyauth = require('everyauth')
1383 , connect = require('connect');
1384
1385 everyauth.mailru
1386 .appId('YOUR CONSUMER KEY HERE')
1387 .appSecret('YOUR CONSUMER SECRET HERE')
1388 .scope('messages')
1389 .entryPath('/auth/mailru')
1390 .callbackPath('/auth/mailru/callback')
1391 .findOrCreateUser( function (session, accessToken, accessTokenExtra, mailruUser) {
1392 // find or create user logic goes here
1393 // Return a user or Promise that promises a user
1394 // Promises are created via
1395 // var promise = this.Promise();
1396 // return promise;
1397 })
1398 .redirectPath('/');
1399
1400 var routes = function (app) {
1401 // Define your routes here
1402 };
1403
1404 connect(
1405 connect.bodyParser()
1406 , connect.cookieParser()
1407 , connect.session({secret: 'whodunnit'})
1408 , everyauth.middleware()
1409 , connect.router(routes);
1410 ).listen(3000);
1411 ```
1412
39f53ba @bnoguchi More succint headers
authored
1413 ### Yahoo OAuth
3679ab8 @bnoguchi Added Yahoo module instructions to README
authored
1414
1415 ```javascript
1416 var everyauth = require('everyauth')
1417 , connect = require('connect');
1418
1419 everyauth.yahoo
1420 .consumerKey('YOUR CONSUMER KEY HERE')
1421 .consumerSecret('YOUR CONSUMER SECRET HERE')
1422 .findOrCreateUser( function (session, accessToken, accessTokenSecret, yahooUserMetadata) {
1423 // find or create user logic goes here
1424 })
1425 .redirectPath('/');
1426
1427 var routes = function (app) {
1428 // Define your routes here
1429 };
1430
1431 connect(
1432 connect.bodyParser()
1433 , connect.cookieParser()
1434 , connect.session({secret: 'whodunnit'})
1435 , everyauth.middleware()
1436 , connect.router(routes);
1437 ).listen(3000);
1438 ```
1439
1440 You can also configure more parameters (most are set to defaults) via
1441 the same chainable API:
1442
8ca1f5f @christophlsa whitespaces at the end of lines in README removed
christophlsa authored
1443 ```javascript
3679ab8 @bnoguchi Added Yahoo module instructions to README
authored
1444 everyauth.yahoo
1445 .entryPath('/auth/yahoo')
1446 .callbackPath('/auth/yahoo/callback');
1447 ```
1448
1449 If you want to see what the current value of a
1450 configured parameter is, you can do so via:
1451
1452 ```javascript
1453 everyauth.yahoo.callbackPath(); // '/auth/yahoo/callback'
1454 everyauth.yahoo.entryPath(); // '/auth/yahoo'
1455 ```
1456
1457 To see all parameters that are configurable, the following will return an
1458 object whose parameter name keys map to description values:
1459
1460 ```javascript
1461 everyauth.yahoo.configurable();
1462 ```
4c9bd57 @bnoguchi Updated README for google module.
authored
1463
39f53ba @bnoguchi More succint headers
authored
1464 ### Readability OAuth
7cfaa91 @bnoguchi Added instructions to README for the readability module.
authored
1465
1466 ```javascript
1467 var everyauth = require('everyauth')
1468 , connect = require('connect');
1469
1470 everyauth.readability
1471 .consumerKey('YOUR CONSUMER KEY HERE')
1472 .consumerSecret('YOUR CONSUMER SECRET HERE')
1473 .findOrCreateUser( function (sess, accessToken, accessSecret, reader) {
1474 // find or create user logic goes here
1475 //
1476 // e.g.,
61a2177 @bnoguchi Fixed mistake in example and documentation for Readability module whe…
authored
1477 // return usersByReadabilityId[reader.username] || (usersByReadabilityId[reader.username] = reader);
7cfaa91 @bnoguchi Added instructions to README for the readability module.
authored
1478 })
1479 .redirectPath('/');
1480
1481 var routes = function (app) {
1482 // Define your routes here
1483 };
1484
1485 connect(
1486 connect.bodyParser()
1487 , connect.cookieParser()
1488 , connect.session({secret: 'whodunnit'})
1489 , everyauth.middleware()
1490 , connect.router(routes);
1491 ).listen(3000);
1492 ```
1493
1494 You can also configure more parameters (most are set to defaults) via
1495 the same chainable API:
1496
8ca1f5f @christophlsa whitespaces at the end of lines in README removed
christophlsa authored
1497 ```javascript
7cfaa91 @bnoguchi Added instructions to README for the readability module.
authored
1498 everyauth.readability
1499 .entryPath('/auth/readability')
1500 .callbackPath('/auth/readability/callback');
1501 ```
1502
1503 If you want to see what the current value of a
1504 configured parameter is, you can do so via:
1505
1506 ```javascript
1507 everyauth.readability.callbackPath(); // '/auth/readability/callback'
1508 everyauth.readability.entryPath(); // '/auth/readability'
1509 ```
1510
1511 To see all parameters that are configurable, the following will return an
1512 object whose parameter name keys map to description values:
1513
1514 ```javascript
1515 everyauth.readability.configurable();
1516 ```
1517
39f53ba @bnoguchi More succint headers
authored
1518 ### Dropbox OAuth
1677cc0 @bnoguchi Added Dropbox documentation and credits (thanks, Torgeir) to the README
authored
1519
1520 ```javascript
1521 var everyauth = require('everyauth')
1522 , connect = require('connect');
1523
1524 everyauth.dropbox
1525 .consumerKey('YOUR CONSUMER KEY HERE')
1526 .consumerSecret('YOUR CONSUMER SECRET HERE')
1527 .findOrCreateUser( function (sess, accessToken, accessSecret, user) {
1528 // find or create user logic goes here
1529 //
1530 // e.g.,
1531 // return usersByDropboxId[user.uid] || (usersByDropboxId[user.uid] = user);
1532 })
1533 .redirectPath('/');
1534
1535 var routes = function (app) {
1536 // Define your routes here
1537 };
1538
1539 connect(
1540 connect.bodyParser()
1541 , connect.cookieParser()
1542 , connect.session({secret: 'whodunnit'})
1543 , everyauth.middleware()
1544 , connect.router(routes);
1545 ).listen(3000);
1546 ```
1547
1548 You can also configure more parameters (most are set to defaults) via
1549 the same chainable API:
1550
8ca1f5f @christophlsa whitespaces at the end of lines in README removed
christophlsa authored
1551 ```javascript
1677cc0 @bnoguchi Added Dropbox documentation and credits (thanks, Torgeir) to the README
authored
1552 everyauth.dropbox
1553 .entryPath('/auth/dropbox')
1554 .callbackPath('/auth/dropbox/callback');
1555 ```
1556
1557 If you want to see what the current value of a
1558 configured parameter is, you can do so via:
1559
1560 ```javascript
1561 everyauth.dropbox.callbackPath(); // '/auth/dropbox/callback'
1562 everyauth.dropbox.entryPath(); // '/auth/dropbox'
1563 ```
1564
1565 To see all parameters that are configurable, the following will return an
1566 object whose parameter name keys map to description values:
1567
1568 ```javascript
1569 everyauth.dropbox.configurable();
1570 ```
1571
39f53ba @bnoguchi More succint headers
authored
1572 ### Justin.tv OAuth
0255f91 @slickplaid Updated README.md
slickplaid authored
1573
1574 [Sign up for a Justin.tv account](http://www.justin.tv/user/signup) and activate it as a [developer account](http://www.justin.tv/developer/activate) to get your consumer key and secret.
1575
1576 ```javascript
1577 var everyauth = require('everyauth')
1578 , connect = require('connect');
1579
1580 everyauth.justintv
1581 .consumerKey('YOUR CONSUMER KEY HERE')
1582 .consumerSecret('YOUR CONSUMER SECRET HERE')
1583 .findOrCreateUser( function (sess, accessToken, accessSecret, justintvUser) {
1584 // find or create user logic goes here
1585 //
1586 // e.g.,
1587 // return usersByJustintvId[justintvUser.id] || (usersByJustintvId[justintvUser.id] = justintvUser);
1588 })
1589 .redirectPath('/');
1590
1591 var routes = function (app) {
1592 // Define your routes here
1593 };
1594
1595 connect(
1596 connect.bodyParser()
1597 , connect.cookieParser()
1598 , connect.session({secret: 'whodunnit'})
1599 , everyauth.middleware()
1600 , connect.router(routes);
1601 ).listen(3000);
1602 ```
1603
1604 The `justintvUser` parameter in the `.findOrCreateUser()` function above returns the `account/whoami` API call
1605
1606 [Justin.tv API Wiki - Account/whoami](http://apiwiki.justin.tv/mediawiki/index.php/Account/whoami)
1607
1608 ```javascript
1609 {
1610 "image_url_huge": "http:\/\/static-cdn.justin.tv\/jtv_user_pictures\/justin-320x240-4.jpg",
1611 "profile_header_border_color": null,
1612 "favorite_quotes": "I love Justin.tv",
1613 "sex": "Male",
1614 "image_url_large": "http:\/\/static-cdn.justin.tv\/jtv_user_pictures\/justin-125x94-4.jpg",
1615 "profile_about": "Check out my website:\n\nwww.justin.tv\n",
1616 "profile_background_color": null,
1617 "image_url_medium": "http:\/\/static-cdn.justin.tv\/jtv_user_pictures\/justin-75x56-4.jpg",
1618 "id": 1698,
1619 "broadcaster": true,
1620 "profile_url": "http:\/\/www.justin.tv\/justin\/profile",
1621 "profile_link_color": null,
1622 "image_url_small": "http:\/\/static-cdn.justin.tv\/jtv_user_pictures\/justin-50x37-4.jpg",
1623 "profile_header_text_color": null,
1624 "name": "The JUST UN",
1625 "image_url_tiny": "http:\/\/static-cdn.justin.tv\/jtv_user_pictures\/justin-33x25-4.jpg",
1626 "login": "justin",
1627 "profile_header_bg_color": null,
1628 "location": "San Francisco"
1629 }
1630 ```
1631
1632 You can also configure more parameters (most are set to defaults) via the same chainable API:
1633
1634 ```javascript
1635 everyauth.justintv
1636 .entryPath('/auth/justintv')
1637 .callbackPath('/auth/justintv/callback');
1638 ```
1639
1640 If you want to see what the current value of a configured parameter is, you can do so via:
1641
1642 ```javascript
1643 everyauth.justintv.callbackPath(); // '/auth/justintv/callback'
1644 everyauth.justintv.entryPath(); // '/auth/justintv'
1645 ```
1646
1647 To see all parameters that are configurable, the following will return an object whose parameter name keys map to description values:
1648
1649 ```javascript
1650 everyauth.justintv.configurable();
1651 ```
1652
39f53ba @bnoguchi More succint headers
authored
1653 ### Vimeo OAuth
bfd500c @slickplaid Edited README.md
slickplaid authored
1654
1655 You will first need to sign up for a [developer application](http://vimeo.com/api/applications) to get the consumer key and secret.
1656
1657 ```javascript
1658 var everyauth = require('everyauth')
1659 , connect = require('connect');
1660
1661 everyauth.vimeo
1662 .consumerKey('YOUR CONSUMER KEY HERE')
1663 .consumerSecret('YOUR CONSUMER SECRET HERE')
1664 .findOrCreateUser( function (sess, accessToken, accessSecret, user) {
1665 // find or create user logic goes here
1666 //
1667 // e.g.,
1668 // return usersByVimeoId[user.id] || (usersByVimeoId[user.id] = user);
1669 })
1670 .redirectPath('/');
1671
1672 var routes = function (app) {
1673 // Define your routes here
1674 };
1675
1676 connect(
1677 connect.bodyParser()
1678 , connect.cookieParser()
1679 , connect.session({secret: 'whodunnit'})
1680 , everyauth.middleware()
1681 , connect.router(routes);
1682 ).listen(3000);
1683 ```
1684
1685 You can also configure more parameters (most are set to defaults) via
1686 the same chainable API:
1687
8ca1f5f @christophlsa whitespaces at the end of lines in README removed
christophlsa authored
1688 ```javascript
bfd500c @slickplaid Edited README.md
slickplaid authored
1689 everyauth.vimeo
1690 .entryPath('/auth/vimeo')
1691 .callbackPath('/auth/vimeo/callback');
1692 ```
1693
1694 If you want to see what the current value of a
1695 configured parameter is, you can do so via:
1696
1697 ```javascript
1698 everyauth.vimeo.callbackPath(); // '/auth/vimeo/callback'
1699 everyauth.vimeo.entryPath(); // '/auth/vimeo'
1700 ```
1701
1702 To see all parameters that are configurable, the following will return an
1703 object whose parameter name keys map to description values:
1704
1705 ```javascript
1706 everyauth.vimeo.configurable();
1707 ```
1708
39f53ba @bnoguchi More succint headers
authored
1709 ### Tumblr OAuth (1.a)
6bdf1ef @bnoguchi Added tumblr instructions to the README
authored
1710
1711 You will first need to [register an app](http://www.tumblr.com/oauth/register) to get the consumer key and secret.
1712 During registration of your new app, enter a "Default callback URL" of "http://<hostname>:<port>/auth/tumblr/callback".
1713 Once you register your app, copy down your "OAuth Consumer Key" and "Secret Key" and proceed below.
1714
1715 ```javascript
1716 var everyauth = require('everyauth')
1717 , connect = require('connect');
1718
1719 everyauth.tumblr
1720 .consumerKey('YOUR CONSUMER KEY HERE')
1721 .consumerSecret('YOUR CONSUMER SECRET HERE')
1722 .findOrCreateUser( function (sess, accessToken, accessSecret, user) {
1723 // find or create user logic goes here
1724 //
1725 // e.g.,
1726 // return usersByTumblrName[user.name] || (usersByTumblrName[user.name] = user);
1727 })
1728 .redirectPath('/');
1729
1730 var routes = function (app) {
1731 // Define your routes here
1732 };
1733
1734 connect(
1735 connect.bodyParser()
1736 , connect.cookieParser()
1737 , connect.session({secret: 'whodunnit'})
1738 , everyauth.middleware()
1739 , connect.router(routes);
1740 ).listen(3000);
1741 ```
1742
1743 You can also configure more parameters (most are set to defaults) via
1744 the same chainable API:
1745
8ca1f5f @christophlsa whitespaces at the end of lines in README removed
christophlsa authored
1746 ```javascript
6bdf1ef @bnoguchi Added tumblr instructions to the README
authored
1747 everyauth.tumblr
1748 .entryPath('/auth/tumblr')
1749 .callbackPath('/auth/tumblr/callback');
1750 ```
1751
1752 If you want to see what the current value of a
1753 configured parameter is, you can do so via:
1754
1755 ```javascript
1756 everyauth.tumblr.callbackPath(); // '/auth/tumblr/callback'
1757 everyauth.tumblr.entryPath(); // '/auth/tumblr'
1758 ```
1759
1760 To see all parameters that are configurable, the following will return an
1761 object whose parameter name keys map to description values:
1762
1763 ```javascript
1764 everyauth.tumblr.configurable();
1765 ```
1766
39f53ba @bnoguchi More succint headers
authored
1767 ### Evernote OAuth (1.a)
7484bc2 Updated readme to include Evernote
Danny Amey authored
1768
1769 You will first need to [request an API key](http://www.evernote.com/about/developer/api/#key) to get the consumer key and secret. Note that this consumer key and secret will only be valid for the sandbox rather than the production OAuth host. By default the Evernote module will use the production host, so you'll need to override this using the chainable API if you're using the sandbox.
1770
1771 ```javascript
1772 var everyauth = require('everyauth')
1773 , connect = require('connect');
1774
1775 everyauth.evernote
1776 .consumerKey('YOUR CONSUMER KEY HERE')
1777 .consumerSecret('YOUR CONSUMER SECRET HERE')
1778 .findOrCreateUser( function (sess, accessToken, accessSecret, user) {
1779 // find or create user logic goes here
1780 //
1781 // e.g.,
1782 // return usersByEvernoteId[user.userId] || (usersByEvernoteId[user.userId] = user);
1783 })
1784 .redirectPath('/');
1785
1786 var routes = function (app) {
1787 // Define your routes here
1788 };
1789
1790 connect(
1791 connect.bodyParser()
1792 , connect.cookieParser()
1793 , connect.session({secret: 'whodunnit'})
1794 , everyauth.middleware()
1795 , connect.router(routes);
1796 ).listen(3000);
1797 ```
1798
1799 You can also configure more parameters (most are set to defaults) via
1800 the same chainable API:
1801
8ca1f5f @christophlsa whitespaces at the end of lines in README removed
christophlsa authored
1802 ```javascript
7484bc2 Updated readme to include Evernote
Danny Amey authored
1803 everyauth.evernote
1804 .oauthHost('https://sandbox.evernote.com')
1805 .entryPath('/auth/evernote')
1806 .callbackPath('/auth/evernote/callback');
1807 ```
1808
1809 If you want to see what the current value of a
1810 configured parameter is, you can do so via:
1811
1812 ```javascript
1813 everyauth.evernote.oauthHost(); // 'https://sandbox.evernote.com'
1814 everyauth.evernote.callbackPath(); // '/auth/evernote/callback'
1815 everyauth.evernote.entryPath(); // '/auth/evernote'
1816 ```
1817
1818 To see all parameters that are configurable, the following will return an
1819 object whose parameter name keys map to description values:
1820
1821 ```javascript
1822 everyauth.evernote.configurable();
b997152 @christophlsa OSM added to README
christophlsa authored
1823 ```
1824
39f53ba @bnoguchi More succint headers
authored
1825 ### OpenStreetMap OAuth
b997152 @christophlsa OSM added to README
christophlsa authored
1826
1827 You will first need to [login to OpenStreetMap](http://www.openstreetmap.org). Then register you application on your OpenStreetMap user page via the View my OAuth details link on the bottom of the page to get the consumer key and secret. The registered application does not need any permission listed there to login via OAuth.
1828
1829 ```javascript
1830 var everyauth = require('osm')
1831 , connect = require('connect');
1832
1833 everyauth.osm
1834 .consumerKey('YOUR CONSUMER KEY HERE')
1835 .consumerSecret('YOUR CONSUMER SECRET HERE')
1836 .findOrCreateUser( function (sess, accessToken, accessSecret, user) {
1837 // find or create user logic goes here
1838 //
1839 // e.g.,
1840 // return usersByOSMId[user.id] || (usersByOSMId[user.id] = user);
1841 })
1842 .redirectPath('/');
1843
1844 var routes = function (app) {
1845 // Define your routes here
1846 };
1847
1848 connect(
1849 connect.bodyParser()
1850 , connect.cookieParser()
1851 , connect.session({secret: 'whodunnit'})
1852 , everyauth.middleware()
1853 , connect.router(routes);
1854 ).listen(3000);
1855 ```
1856
1857 You can also configure more parameters (most are set to defaults) via
1858 the same chainable API:
1859
1860 ```javascript
1861 everyauth.osm
1862 .oauthHost('http://api06.dev.openstreetmap.org')
1863 .entryPath('/auth/osm')
1864 .callbackPath('/auth/osm/callback');
1865 ```
1866
1867 If you want to see what the current value of a
1868 configured parameter is, you can do so via:
1869
1870 ```javascript
1871 everyauth.osm.oauthHost(); // 'http://api.openstreetmap.org'
1872 everyauth.osm.callbackPath(); // '/auth/osm/callback'
1873 everyauth.osm.entryPath(); // '/auth/osm'
1874 ```
1875
1876 To see all parameters that are configurable, the following will return an
1877 object whose parameter name keys map to description values:
1878
1879 ```javascript
1880 everyauth.osm.configurable();
7484bc2 Updated readme to include Evernote
Danny Amey authored
1881 ```
1882
39f53ba @bnoguchi More succint headers
authored
1883 ### TripIt OAuth (1.0)
185c6ff @pirxpilot Modify everyauth documentation for TripIt OAuth
pirxpilot authored
1884
1885 Obtain consumer key and consumer secret for your app by [registering it](http://www.tripit.com/developer/create).
1886 Please note that TripIt is using _API Key_ and _API Secret_ terminology: use those values as describe below.
1887
1888 ```javascript
1889 var everyauth = require('everyauth')
1890 , connect = require('connect');
1891
1892 everyauth.tripit
1893 .consumerKey('YOUR API KEY')
1894 .consumerSecret('YOUR API SECRET')
1895 .findOrCreateUser( function (sess, accessToken, accessSecret, tripitProfile) {
1896 // find or create user logic goes here
1897 })
1898 .redirectPath('/');
1899
1900 var routes = function (app) {
1901 // Define your routes here
1902 };
1903
1904 connect(
1905 connect.bodyParser()
1906 , connect.cookieParser()
1907 , connect.session({secret: 'whodunnit'})
1908 , everyauth.middleware()
1909 , connect.router(routes);
1910 ).listen(3000);
1911 ```
1912
39f53ba @bnoguchi More succint headers
authored
1913 ### 500px OAuth (1.0)
4305188 Add 500px OAuth 1.0 support
Danny Amey authored
1914
1915 You will first need to [request an API key](http://developer.500px.com/oauth_clients/new) to get the consumer key and secret.
1916
1917 ```javascript
1918 var everyauth = require('everyauth')
1919 , connect = require('connect');
1920
1921 everyauth['500px']
1922 .consumerKey('YOUR CONSUMER KEY HERE')
1923 .consumerSecret('YOUR CONSUMER SECRET HERE')
1924 .findOrCreateUser( function (sess, accessToken, accessSecret, user) {
1925 // find or create user logic goes here
1926 //
1927 // e.g.,
1928 // return usersBy500pxId[user.userId] || (usersBy500pxId[user.userId] = user);
1929 })
1930 .redirectPath('/');
1931
1932 var routes = function (app) {
1933 // Define your routes here
1934 };
1935
1936 connect(
1937 connect.bodyParser()
1938 , connect.cookieParser()
1939 , connect.session({secret: 'whodunnit'})
1940 , everyauth.middleware()
1941 , connect.router(routes);
1942 ).listen(3000);
a548809 @bnoguchi README formatting fix
authored
1943 ```
4305188 Add 500px OAuth 1.0 support
Danny Amey authored
1944
9bbf104 @cleishm Additional usage documentation
cleishm authored
1945 ### SoundCloud OAuth2
1946
1947 You will first need to [register an app](http://soundcloud.com/you/apps) to get the client id and secret.
1948 During registration of your new app, enter a "Default callback URL" of "http://<hostname>:<port>/auth/soundcloud/callback".
1949 Once you register your app, copy down your "Client ID" and "Client Secret" and proceed below.
1950
1951 ```javascript
1952 var everyauth = require('everyauth')
1953 , connect = require('connect');
1954
1955 everyauth.soundcloud
1956 .appId('YOUR CLIENT ID HERE')
1957 .appSecret('YOUR CLIENT SECRET HERE')
1958 .handleAuthCallbackError( function (req, res) {
1959 // TODO - Update this documentation
1960 // This configurable route handler defines how you want to respond to
1961 // a response from SoundCloud that something went wrong during the oauth2 process.
1962 // If you do not configure this, everyauth renders a default fallback
1963 // view notifying the user that their authentication failed and why.
1964 })
1965 .findOrCreateUser( function (session, accessToken, accessTokenExtra, soundcloudUserMetadata) {
1966 // find or create user logic goes here
1967 // Return a user or Promise that promises a user
1968 // Promises are created via
1969 // var promise = this.Promise();
1970 })
1971 .redirectPath('/');
1972
1973 var routes = function (app) {
1974 // Define your routes here
1975 };
1976
1977 connect(
1978 connect.bodyParser()
1979 , connect.cookieParser()
1980 , connect.session({secret: 'whodunnit'})
1981 , everyauth.middleware()
1982 , connect.router(routes);
1983 ).listen(3000);
1984 ```
1985
1986 You can also configure more parameters (most are set to defaults) via
1987 the same chainable API:
1988
1989 ```javascript
1990 everyauth.soundcloud
1991 .entryPath('/auth/soundcloud')
1992 .callbackPath('/auth/soundcloud/callback');
1993 ```
1994
1995 If you want to see what the current value of a
1996 configured parameter is, you can do so via:
1997
1998 ```javascript
1999 everyauth.soundcloud.scope(); // undefined
2000 everyauth.soundcloud.display(); // undefined
2001 everyauth.soundcloud.entryPath(); // '/auth/soundcloud'
2002 ```
2003
2004 To see all parameters that are configurable, the following will return an
2005 object whose parameter name keys map to description values:
2006
2007 ```javascript
2008 everyauth.soundcloud.configurable();
2009 ```
2010
209deef @ainoya add mixi.js and edit README.md
ainoya authored
2011 ### mixi OAuth2
2012
2013 First, register an app [on mixi](http://developer.mixi.co.jp).
2014
2015 ```javascript
2016 var everyauth = require('everyauth')
2017 , connect = require('connect');
2018
2019 everyauth.mixi
3367e03 @ainoya modify README.md
ainoya authored
2020 .appId('YOUR CONSUMER KEY HERE')
2021 .appSecret('YOUR CONSUMER SECRET HERE')
209deef @ainoya add mixi.js and edit README.md
ainoya authored
2022 .display('pc') //specify device types of access: See http://developers.mixi.co.jp/
2023 .scope('r_profile') //specify types of access: See http://developers.mixi.co.jp/
2024 .findOrCreateUser( function (session, accessToken, accessTokenExtra, mixiUserMetadata) {
2025 // find or create user logic goes here
2026 // Return a user or Promise that promises a user
2027 // Promises are created via
2028 // var promise = this.Promise();
2029 })
2030 .redirectPath('/');
2031
2032 var routes = function (app) {
2033 // Define your routes here
2034 };
2035 ```
185c6ff @pirxpilot Modify everyauth documentation for TripIt OAuth
pirxpilot authored
2036
9038bf6 @wnadeau README updated for mailchimp hoobajooba
wnadeau authored
2037 ### Mailchimp OAuth2
2038
2039 First, register an app [in Mailchimp](http://login.mailchimp.com).
2040
2041 ```javascript
2042 var everyauth = require('everyauth')
2043 , connect = require('connect');
2044
2045 everyauth.mailchimp
2046 .appId('YOUR CLIENT KEY HERE')
2047 .appSecret('YOUR CLIENT SECRET HERE')
2048 .myHostname(process.env.HOSTNAME || "http://127.0.0.1:3000")//MC requires 127.0.0.1 for dev
2049 .findOrCreateUser( function (session, accessToken, accessTokenExtra, mailchimpUserData) {
2050 // find or create user logic goes here
2051 // Return a user or Promise that promises a user
2052 // Promises are created via
2053 // var promise = this.Promise();
2054 // The mailchimpUserData object contains everything from the API method getAccountDetails and an apikey.
2055 // You'll want to work with mailchimpUserData.user_id for queries
2056 // and mailchimpUserData.apikey for your API wrapper
2057 })
2058 .redirectPath('/');
2059
2060 var routes = function (app) {
2061 // Define your routes here
2062 };
d74d6a8 @bnoguchi Merge branch 'master' of https://github.com/edy-b/everyauth into edy-…
authored
2063
2064 connect(
2065 connect.bodyParser()
2066 , connect.cookieParser()
2067 , connect.session({secret: 'whodunnit'})
2068 , everyauth.middleware()
2069 , connect.router(routes);
2070 ).listen(3000);
2071 ```
2072
2073 ### Mendeley OAuth (1.0)
2074
2075 You will first need to [register your application](http://dev.mendeley.com/applications/register/) to get the consumer key and secret.
2076
2077 ```javascript
3ba53d8 @edy Add Mendeley OAuth support
edy authored
2078 everyauth.mendeley
2079 .consumerKey('YOUR CONSUMER KEY HERE')
2080 .consumerSecret('YOUR CONSUMER SECRET HERE')
2081 .findOrCreateUser( function (sess, accessToken, accessSecret, user) {
2082 // find or create user logic goes here
2083 //
2084 // e.g.,
2085 // return usersByMendeleyId[user.main.profile_id] || (usersByMendeleyId[user.main.profile_id] = user);
2086 })
2087 .redirectPath('/');
2088
2089 var routes = function (app) {
2090 // Define your routes here
2091 };
2092
2093 connect(
2094 connect.bodyParser()
2095 , connect.cookieParser()
2096 , connect.session({secret: 'whodunnit'})
2097 , everyauth.middleware()
2098 , connect.router(routes);
2099 ).listen(3000);
9038bf6 @wnadeau README updated for mailchimp hoobajooba
wnadeau authored
2100 ```
2101
39f53ba @bnoguchi More succint headers
authored
2102 ### OpenID protocol
6dfe84b @deedubs documentation/example changes requested by @bnoguchi
deedubs authored
2103
3ab6b7b @bnoguchi Placed OpenID instructions before OpenID + Google Hybrid instructions…
authored
2104 OpenID protocol allows you to use an openid auth request. You can read more information about it here http://openid.net/
1e57127 @deedubs readme additions for google openid-hybrid
deedubs authored
2105
2106 ```javascript
2107 var everyauth = require('everyauth')
2108 , connect = require('connect');
2109
3ab6b7b @bnoguchi Placed OpenID instructions before OpenID + Google Hybrid instructions…
authored
2110 everyauth.openid
f3b91e9 @bnoguchi Added myHostname config to README openid instructions.
authored
2111 .myHostname('http://localhost:3000')
3ab6b7b @bnoguchi Placed OpenID instructions before OpenID + Google Hybrid instructions…
authored
2112 .simpleRegistration({