# @creamery/oauth2client

> A simple oauth2 client

Latest version **1.0.1** (published 2017-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @creamery/oauth2client
pnpm add @creamery/oauth2client
yarn add @creamery/oauth2client
bun add @creamery/oauth2client
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-08-17 |
| First published | 2017-08-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | creamidea@gmail.com |
| Maintainers | creamidea |
| Keywords | oauth2, client |

## Links

- npm: https://www.npmjs.com/package/@creamery/oauth2client
- Repository: https://github.com/creamidea/Oauth2Client
- Homepage: https://github.com/creamidea/Oauth2Client#readme
- Issues: https://github.com/creamidea/Oauth2Client/issues
- npm.io page: https://npm.io/package/@creamery/oauth2client

## Dependencies (1)

- [request](https://npm.io/package/request.md) ^2.81.0

## 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
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2017-08-17
- 1.0.0 — 2017-08-15

## README

# Oauth2Client
A simple oauth2 client

# Usage
```javascript
const Oauth2Client = require('@creamery/oauth2client')

const oauth2Client = new Oauth2Client({
  baseUrl,
  oauthPath,
  tokenPath,
  redirectURI,
  appId,
  appSecret
})

// and then you can use it like the code below
app.use(async (ctx, next) => {
  ...
  // here assume that is the code
  if (ctx.query.code) {
    const body = oauth2Client.requestToken(code)
    ctx.session.accessToken = body.access_token
    // if calling requestToken is failed,
    // it will throw the ERROR. You can catch it.
  }
  ...

  if (!ctx.session.accessToken) {
    oauth2Client.redirectToAuthorizedURI(ctx)
    ...
  }
  ...
})
```

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