ot-passport-password-grant
v0.0.15
Published
Password grant OAuth2.0 strategy for Passport.
Downloads
4
Maintainers
Readme
passport-password-grant
HTTP OAuth2.0 Password Grant authentication strategy for Passport.
This module lets you authenticate users via username and password provided to an authozization server using a password grant REST call and receiving a access token and refresh token issued using OAuth 2.0.
Usage
Configure Strategy
The grant strategy will return a token containing token.access_token
and token.refresh_token
passport.use(new GrantStrategy({
usernameField: 'email',
passwordField: 'password',
clientId: 'theClientId',
scope: 'theScope',
host: 'https://auth.server'
port: '8443',
function(token, done) {
// Do something with the token
}
));
Authenticate Requests
Use passport.authenticate()
, specifying the 'password-grant'
strategy, to
authenticate requests.
passport.authenticate('password-grant',
function(req, res) {
res.json(req.user);
}
);