OAuth 2.0 authentication strategy for Passport.
General-purpose OAuth 2.0 authentication strategy for Passport.
This module lets you authenticate using OAuth 2.0 in your Node.js applications. By plugging into Passport, OAuth 2.0 authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
Note that this strategy provides generic OAuth 2.0 support. In many cases, a provider-specific strategy can be used instead, which cuts down on unnecessary configuration, and accommodates any provider-specific quirks. See the list for supported providers.
Developers who need to implement authentication against an OAuth 2.0 provider that is not already supported are encouraged to sub-class this strategy. If you choose to open source the new provider-specific strategy, please add it to the list so other people can find it.
$ npm install passport-oauth2
The OAuth 2.0 authentication strategy authenticates users using a third-party
account and OAuth 2.0 tokens. The provider's OAuth 2.0 endpoints, as well as
the client identifer and secret, are specified as options. The strategy
verify callback, which receives an access token and profile,
done providing a user.
passportuseauthorizationURL: ''tokenURL: ''clientID: EXAMPLE_CLIENT_IDclientSecret: EXAMPLE_CLIENT_SECRETcallbackURL: ""UserfindOrCreate exampleId: profileidreturn doneerr user;;;
passport.authenticate(), specifying the
'oauth2' strategy, to
For example, as route middleware in an Express application:
appget'/auth/example'passportauthenticate'oauth2';appget'/auth/example/callback'passportauthenticate'oauth2' failureRedirect: '/login'// Successful authentication, redirect home.resredirect'/';;
$ npm install$ npm test
Copyright (c) 2011-2015 Jared Hanson <http://jaredhanson.net/>