Skip to content
This repository
Browse code

Update README.

  • Loading branch information...
commit 4da6bc43ea4e6e066044c675b1072ccc71c307ac 1 parent 9207bb3
Jared Hanson authored January 11, 2012

Showing 1 changed file with 56 additions and 0 deletions. Show diff stats Hide diff stats

  1. 56  README.md
56  README.md
Source Rendered
@@ -3,6 +3,62 @@
3 3
 [Passport](https://github.com/jaredhanson/passport) strategy for authenticating
4 4
 with Yammer using the OAuth 2.0 API.
5 5
 
  6
+## Installation
  7
+
  8
+    $ npm install passport-yammer
  9
+
  10
+## Usage
  11
+
  12
+#### Configure Strategy
  13
+
  14
+The Yammer authentication strategy authenticates users using a Yammer
  15
+account and OAuth 2.0 tokens.  The strategy requires a `verify` callback, which
  16
+accepts these credentials and calls `done` providing a user, as well as
  17
+`options` specifying a client ID, client secret, and callback URL.
  18
+
  19
+    passport.use(new YammerStrategy({
  20
+        clientID: YAMMER_CONSUMER_KEY,
  21
+        clientSecret: YAMMER_CONSUMER_SECRET,
  22
+        callbackURL: "http://127.0.0.1:3000/auth/yammer/callback"
  23
+      },
  24
+      function(accessToken, refreshToken, profile, done) {
  25
+        User.findOrCreate({ yammerId: profile.id }, function (err, user) {
  26
+          return done(err, user);
  27
+        });
  28
+      }
  29
+    ));
  30
+
  31
+#### Authenticate Requests
  32
+
  33
+Use `passport.authenticate()`, specifying the `'yammer'` strategy, to
  34
+authenticate requests.
  35
+
  36
+For example, as route middleware in an [Express](http://expressjs.com/)
  37
+application:
  38
+
  39
+    app.get('/auth/yammer',
  40
+      passport.authenticate('yammer'),
  41
+      function(req, res){
  42
+        // The request will be redirected to Yammer for authentication, so
  43
+        // this function will not be called.
  44
+      });
  45
+
  46
+    app.get('/auth/yammer/callback', 
  47
+      passport.authenticate('yammer', { failureRedirect: '/login' }),
  48
+      function(req, res) {
  49
+        // Successful authentication, redirect home.
  50
+        res.redirect('/');
  51
+      });
  52
+
  53
+## Examples
  54
+
  55
+For a complete, working example, refer to the [login example](https://github.com/jaredhanson/passport-yammer/tree/master/examples/login).
  56
+
  57
+## Tests
  58
+
  59
+    $ npm install --dev
  60
+    $ make test
  61
+
6 62
 ## Credits
7 63
 
8 64
   - [Jared Hanson](http://github.com/jaredhanson)

0 notes on commit 4da6bc4

Please sign in to comment.
Something went wrong with that request. Please try again.