# kong-utility-client

> Utility function for kong api

Latest version **0.0.8** (published 2019-07-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install kong-utility-client
pnpm add kong-utility-client
yarn add kong-utility-client
bun add kong-utility-client
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.8 |
| Published | 2019-07-08 |
| First published | 2019-04-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 23.5 KB |
| Known vulnerabilities | 0 (+24 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Thanachote Khaosanit |
| Maintainers | boshido, bossbossk20, doctoraod, jokergn, kazekun, nantaphop, preferalias, tosbodes, yanaice |
| Keywords | kong, kong-client |

## Links

- npm: https://www.npmjs.com/package/kong-utility-client
- Repository: https://github.com/devit-tel/kong-client
- Homepage: https://github.com/devit-tel/kong-client#readme
- Issues: https://github.com/devit-tel/kong-client/issues
- npm.io page: https://npm.io/package/kong-utility-client

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^0.18.0
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.4.3

## Recent versions

- 0.0.8 (latest) — 2019-07-08
- 0.0.7 — 2019-07-08
- 0.0.6 — 2019-04-09
- 0.0.5 — 2019-04-09
- 0.0.4 — 2019-04-09
- 0.0.3 — 2019-04-09
- 0.0.2 — 2019-04-09
- 0.0.1 — 2019-04-04

## README

# kong-utility-client

## Getting start

```shell
npm install --save kong-utility-client
```

## Connect to Kong

```javascript
import KongClient from 'kong-utility-client'

const kongClient = new KongClient({
  adminURL: 'http://localhost:8001',
  baseURL: 'http://localhost:8000',
  provisionKey: 'some-key'
})
```

## Consumer

### Retrieve Consumer

```javascript
kongClient
  .retrieveConsumer({ name: 'test-kong-client' })
  .then(res => console.log(res.data))
```

### Create Consumer

```javascript
kongClient
  .createConsumer({ name: 'test-kong-client' })
  .then(res => console.log(res))
```

### Delete Consumer

```javascript
kongClient
  .deleteConsumer({ name: 'test-kong-client' })
  .then(res => console.log(res))
```

## Credentials

### Create Oauth Credentials

```javascript
kongClient
createOauthCredential({
  consumerName: 'test-kong-client',
  credentialName: 'test-v2',
  redirectURIs: ['http://localhost:3000/test']
})
  .catch(err => console.log(err))
  .then(res => console.log(res))
```

### Get access token

```javascript
kongClient
  .getAccessToken({
    grantType: 'client_credentials',
    scope: ['USER_ACCESS', 'TMS_ACCESS'],
    authenticatedUserId: 'test-kong-client',
    clientId: 'clientId',
    clientSecret: 'clientSecret'
  })
  .then(res => console.log(res.data))
```

### Refresh access token

```javascript
kongClient
  .refreshAccessToken({
    refreshToken: 'refresh_token',
    clientId: 'clientId',
    clientSecret: 'clientSecret'
  })
  .then(res => console.log(res))
```

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