diff --git a/README.md b/README.md index a31894a..5f42a7a 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -80,8 +84,10 @@ application: ## Tests - $ npm install - $ npm test +``` +$ npm install +$ npm test +``` ## Credits