Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaiklor committed Oct 1, 2015
1 parent 93e77e1 commit 297f1ab
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ unobtrusively integrated into any application or framework that supports

## Usage

#### Configure Strategy
### Configure Strategy

The Facebook authentication strategy authenticates users using a Facebook
account and OAuth 2.0 tokens. The strategy requires a `verify` callback, which
Expand All @@ -35,16 +35,15 @@ accepts these credentials and calls `done` providing a user, as well as
passport.use(new FacebookTokenStrategy({
clientID: FACEBOOK_APP_ID,
clientSecret: FACEBOOK_APP_SECRET
},
function(accessToken, refreshToken, profile, done) {
User.findOrCreate({ facebookId: profile.id }, function (err, user) {
return done(err, user);
}, function(accessToken, refreshToken, profile, done) {
User.findOrCreate({facebookId: profile.id}, function (error, user) {
return done(error, user);
});
}
));
```

#### Authenticate Requests
### Authenticate Requests

Use `passport.authenticate()`, specifying the `'facebook-token'` strategy, to authenticate requests.

Expand All @@ -58,6 +57,20 @@ app.post('/auth/facebook/token',
);
```

Or using Sails framework:

```javascript
// api/controllers/AuthController.js
module.exports = {
facebook: function(req, res) {
passport.authenticate('facebook-token', function(error, user, info) {
// do stuff with user
res.ok();
})(req, res);
}
};
```

The post request to this route should include POST or GET data with the keys `access_token` and optionally, `refresh_token` set to the credentials you receive from facebook.

```
Expand Down

0 comments on commit 297f1ab

Please sign in to comment.