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