Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #221

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,34 @@ app.get('/auth/facebook/callback',
});
```


#### Authenticate Requests with additional custom query data

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


```js

app.get('/auth/facebook', (req, res, next) => {
const { custom } = req.query;
passport.authenticate('facebook', {
callbackURL: `${config.facebook.callbackURL}?custom=${custom}`,
})(req, res, next);
});

app.get('/auth/facebook/callback',
passport.authenticate('facebook', { failureRedirect: '/login' }),
function(req, res) {
// req.query.custom => additional data(some token for example)
// req.query.code => facebook code(secret data, don't send to client)
// req.user => facebook user(sended from FacebookStrategy `return cb(err, user);` )
// Successful authentication, redirect home.
res.redirect('/');
});
```


## Examples

Developers using the popular [Express](http://expressjs.com/) web framework can
Expand Down