Skip to content

Commit

Permalink
Merge 30bb46c into b3d886f
Browse files Browse the repository at this point in the history
  • Loading branch information
CWSpear committed May 9, 2015
2 parents b3d886f + 30bb46c commit 786b8fa
Showing 1 changed file with 29 additions and 23 deletions.
52 changes: 29 additions & 23 deletions README.md
Expand Up @@ -40,19 +40,21 @@ the client identifer and secret, are specified as options. The strategy
requires a `verify` callback, which receives an access token and profile,
and calls `done` providing a user.

passport.use(new OAuth2Strategy({
authorizationURL: 'https://www.example.com/oauth2/authorize',
tokenURL: 'https://www.example.com/oauth2/token',
clientID: EXAMPLE_CLIENT_ID,
clientSecret: EXAMPLE_CLIENT_SECRET,
callbackURL: "http://localhost:3000/auth/example/callback"
},
function(accessToken, refreshToken, profile, done) {
User.findOrCreate({ exampleId: profile.id }, function (err, user) {
return done(err, user);
});
}
));
```js
passport.use(new OAuth2Strategy({
authorizationURL: 'https://www.example.com/oauth2/authorize',
tokenURL: 'https://www.example.com/oauth2/token',
clientID: EXAMPLE_CLIENT_ID,
clientSecret: EXAMPLE_CLIENT_SECRET,
callbackURL: "http://localhost:3000/auth/example/callback"
},
function(accessToken, refreshToken, profile, done) {
User.findOrCreate({ exampleId: profile.id }, function (err, user) {
return done(err, user);
});
}
));
```

#### Authenticate Requests

Expand All @@ -62,15 +64,17 @@ authenticate requests.
For example, as route middleware in an [Express](http://expressjs.com/)
application:

app.get('/auth/example',
passport.authenticate('oauth2'));
```js
app.get('/auth/example',
passport.authenticate('oauth2'));

app.get('/auth/example/callback',
passport.authenticate('oauth2', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/');
});
app.get('/auth/example/callback',
passport.authenticate('oauth2', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/');
});
```

## Related Modules

Expand All @@ -80,8 +84,10 @@ application:

## Tests

$ npm install
$ npm test
```
$ npm install
$ npm test
```

## Credits

Expand Down

0 comments on commit 786b8fa

Please sign in to comment.