# oauth2-server-mongodb

> OAuth2 server implementation with MongoDB integration

Latest version **1.2.0** (published 2019-01-19) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install oauth2-server-mongodb
pnpm add oauth2-server-mongodb
yarn add oauth2-server-mongodb
bun add oauth2-server-mongodb
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2019-01-19 |
| First published | 2019-01-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 170.9 KB |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Elvis Munoz F. |
| Maintainers | lvhjk |

## Links

- npm: https://www.npmjs.com/package/oauth2-server-mongodb
- Repository: https://github.com/ivyhjk/oauth2-server-mongodb
- Homepage: https://github.com/ivyhjk/oauth2-server-mongodb#readme
- Issues: https://github.com/ivyhjk/oauth2-server-mongodb/issues
- npm.io page: https://npm.io/package/oauth2-server-mongodb

## Dependencies (3)

- [argon2](https://npm.io/package/argon2.md) ^0.20.0
- [csprng](https://npm.io/package/csprng.md) ^0.1.2
- [mongoose](https://npm.io/package/mongoose.md) ^5.4.3

## Recent versions

- 1.2.0 (latest) — 2019-01-19
- 1.0.0 — 2019-01-12

## README

# OAuth2 server MongoDB

The goal of this bundle is provide a full implementation of
[oauth2-server](https://github.com/oauthjs/node-oauth2-server) model made with
MongoDB and Mongoose.

## Installation instructions

With Yarn:
```
yarn add oauth2-server-mongodb
```

With NPM:
```
npm install --save oauth2-server-mongodb
```

## Usage

Simple usage:
```javascript
import { MongooseOAuth2 } from 'oauth2-server-mongodb';

const model = new MongooseOAuth2();

// use your model in any oauth2-server implementation
// ...
```

Also you can use your custom models:
```javascript
import { MongooseOAuth2 } from 'oauth2-server-mongodb';
import { User, Token } from './custom-models';

const model = new MongooseOAuth2({ User, Token });

// use your model in any oauth2-server implementation
// ...
```

## Running tests

To run tests we suggest to use the pre-defined MongoDB image with docker-compose:
```
docker-compose up -d
```

And then:
```
yarn tests
```

Alternatively you can create the following environment variables:

| Name                | Default                     |
| :------------------ | :-------------------------- |
| MONGODB_USERNAME    | dummy                       |
| MONGODB_PASSWORD    | dummy                       |
| MONGODB_HOST        | 127.0.0.1                   |
| MONGODB_PORT        | 27017                       |
| MONGODB_DATABASE    | oauth2_server_mongodb_tests |
| MONGODB_AUTH_SOURCE | dummy                       |

And then:
```
yarn tests
```

Also you can edit directly the `tests/database-setup.js` file and use
your own DSN.

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