# optimizely-oauth2

> A tiny module for Optimizely X OAuth2

Latest version **1.0.5** (published 2017-02-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install optimizely-oauth2
pnpm add optimizely-oauth2
yarn add optimizely-oauth2
bun add optimizely-oauth2
```

## 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.5 |
| Published | 2017-02-26 |
| First published | 2017-02-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jimmy Cann |
| Maintainers | yjimk |
| Keywords | Optimizely, Optimizely OAuth |

## Links

- npm: https://www.npmjs.com/package/optimizely-oauth2
- Repository: https://yjimk@github.com/yjimk/optimizely-oauth2
- Homepage: https://github.com/yjimk/optimizely-oauth2#readme
- Issues: https://github.com/yjimk/optimizely-oauth2/issues
- npm.io page: https://npm.io/package/optimizely-oauth2

## Dependencies (4)

- [open](https://npm.io/package/open.md) ^0.0.5
- [express](https://npm.io/package/express.md) ^4.14.1
- [request](https://npm.io/package/request.md) ^2.79.0
- [bluebird](https://npm.io/package/bluebird.md) ^3.4.7

## 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.5 (latest) — 2017-02-26
- 1.0.4 — 2017-02-26
- 1.0.3 — 2017-02-25
- 1.0.2 — 2017-02-25
- 1.0.1 — 2017-02-25

## README

# Optimizely OAuth2

## Why?

To provide a small and lightweight client for Optimizely X OAuth2. This is used in conjunction with the [Optimizely X CLI](https://github.com/yjimk/optx-cli). I thought splitting the two could provide more reusable code, and more value to the community.

## Usage

Start by including the client.

```js
const OptxOauth = require('./lib/optx-oauth')()
```

Optionally, you can also set the following parameters, defaults are provided.

```js
const OptxOauth = require('./lib/optx-oauth')({
  redirectUri: // Defaults to 'http://localhost'
  redirectPort: // Defaults to '8080'
  redirectPath: '/path/for/callback' // Defaults to /authorize
  clientId: 'YOUR_OPTIMIZELY_CLIENT_ID' // This doesn't have to be set on initialization
  clientSecret: 'YOUR_OPTIMIZELY_CLIENT_SECRET' // This doesn't have to be set on initialization
  timeout: 30000 // Otherwise the servers' default timeout is used
})
```

Only two functions are available in this client, `Authorize` and `Refresh`. Nice and simple!

```js
// Opens a new browser window and requests Optimizely authorization.
OptxOauth.Authorize({
  clientId: 'YOUR_OPTIMIZELY_CLIENT_ID', // If you didn't already provide it on initialization
  clientSecret: 'YOUR_OPTIMIZELY_CLIENT_SECRET', // If you didn't already provide it on initialization
  accountId: '4123412' // Your account ID, this is OPTIONAL
})
.then(result => console.log(result))
//{ statusCode: 200,
//  statusMessage: 'OK',
//  body:
//   { access_token: 'GENERATED_ACCESS_TOKEN',
//     token_type: 'bearer',
//     expires_in: 7200,
//     succeeded: true,
//     refresh_token: '2:ea348521f4f44289949ad416503193dc' } }

// Use your refresh token to generate a new access code. Don't have a refresh token? OptxOauth.Authorize and start the process over.
OptxOauth.Refresh({
  clientId: 'YOUR_OPTIMIZELY_CLIENT_ID', // If you didn't already provide it on initialization
  clientSecret: 'YOUR_OPTIMIZELY_CLIENT_SECRET', // If you didn't already provide it on initialization
  refreshToken: 'THE_GENERATED_REFRESH_TOKEN'
})
.then(result => console.log(result))
//{ statusCode: 200,
//  statusMessage: 'OK',
//  body:
//   { access_token: 'GENERATED_ACCESS_TOKEN',
//     token_type: 'bearer',
//     expires_in: 7200,
//     succeeded: true } }
```

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