# passport-oauth2-client-password

> OAuth 2.0 client password authentication strategy for Passport.

Latest version **0.1.2** (published 2014-09-02) · 0 weekly downloads

## Install

```sh
npm install passport-oauth2-client-password
pnpm add passport-oauth2-client-password
yarn add passport-oauth2-client-password
bun add passport-oauth2-client-password
```

## Health

**Score 18/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2014-09-02 |
| First published | 2012-07-11 |
| Weekly downloads | 0 |
| TypeScript types | separate (@types/passport-oauth2-client-password) |
| Module format | CommonJS |
| Node | >= 0.4.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 96 |
| Author | Jared Hanson |
| Maintainers | jaredhanson |
| Keywords | passport, oauth, oauth2, authn, authentication, authz, authorization, api |

## Links

- npm: https://www.npmjs.com/package/passport-oauth2-client-password
- Repository: https://github.com/jaredhanson/passport-oauth2-client-password
- Issues: http://github.com/jaredhanson/passport-oauth2-client-password/issues
- npm.io page: https://npm.io/package/passport-oauth2-client-password

## Dependencies (1)

- [passport-strategy](https://npm.io/package/passport-strategy.md) 1.x.x

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@oxyhq/services](https://npm.io/package/@oxyhq/services.md) — 2.3K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads

## Recent versions

- 0.1.2 (latest) — 2014-09-02
- 0.1.1 — 2013-05-22
- 0.1.0 — 2012-07-11

## README

# passport-oauth2-client-password

OAuth 2.0 client password authentication strategy for [Passport](https://github.com/jaredhanson/passport).

This module lets you authenticate requests containing client credentials in the
request body, as [defined](http://tools.ietf.org/html/draft-ietf-oauth-v2-27#section-2.3.1)
by the OAuth 2.0 specification.  These credentials are typically used protect
the token endpoint and used as an alternative to HTTP Basic authentication.

## Install

    $ npm install passport-oauth2-client-password

## Usage

#### Configure Strategy

The OAuth 2.0 client password authentication strategy authenticates clients
using a client ID and client secret.  The strategy requires a `verify` callback,
which accepts those credentials and calls `done` providing a client.

    passport.use(new ClientPasswordStrategy(
      function(clientId, clientSecret, done) {
        Clients.findOne({ clientId: clientId }, function (err, client) {
          if (err) { return done(err); }
          if (!client) { return done(null, false); }
          if (client.clientSecret != clientSecret) { return done(null, false); }
          return done(null, client);
        });
      }
    ));

#### Authenticate Requests

Use `passport.authenticate()`, specifying the `'oauth2-client-password'`
strategy, to authenticate requests.  This strategy is typically used in
combination with HTTP Basic authentication (as provided by [passport-http](https://github.com/jaredhanson/passport-http)),
allowing clients to include credentials in the request body.

For example, as route middleware in an [Express](http://expressjs.com/)
application, using [OAuth2orize](https://github.com/jaredhanson/oauth2orize)
middleware to implement the token endpoint:

    app.get('/profile', 
      passport.authenticate(['basic', 'oauth2-client-password'], { session: false }),
      oauth2orize.token());

## Examples

The [example](https://github.com/jaredhanson/oauth2orize/tree/master/examples/express2)
included with [OAuth2orize](https://github.com/jaredhanson/oauth2orize)
demonstrates how to implement a complete OAuth 2.0 authorization server.
`ClientPasswordStrategy` is used to authenticate clients as they request access
tokens from the token endpoint.

## Tests

    $ npm install --dev
    $ make test

[![Build Status](https://secure.travis-ci.org/jaredhanson/passport-oauth2-client-password.png)](http://travis-ci.org/jaredhanson/passport-oauth2-client-password)

## Credits

  - [Jared Hanson](http://github.com/jaredhanson)

## License

[The MIT License](http://opensource.org/licenses/MIT)

Copyright (c) 2012-2013 Jared Hanson <[http://jaredhanson.net/](http://jaredhanson.net/)>

---
_Source: https://npm.io/package/passport-oauth2-client-password · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
