ot-passport-password-grant

0.0.15 • Public • Published

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);
      }
    );

License

The MIT License

Package Sidebar

Install

npm i ot-passport-password-grant

Weekly Downloads

0

Version

0.0.15

License

none

Last publish

Collaborators

  • sgautrea