npm.io
0.0.8 • Published 7 years ago

kong-utility-client

Licence
ISC
Version
0.0.8
Deps
2
Size
24 kB
Vulns
24
Weekly
0

kong-utility-client

Getting start

npm install --save kong-utility-client

Connect to Kong

import KongClient from 'kong-utility-client'

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

Consumer

Retrieve Consumer
kongClient
  .retrieveConsumer({ name: 'test-kong-client' })
  .then(res => console.log(res.data))
Create Consumer
kongClient
  .createConsumer({ name: 'test-kong-client' })
  .then(res => console.log(res))
Delete Consumer
kongClient
  .deleteConsumer({ name: 'test-kong-client' })
  .then(res => console.log(res))

Credentials

Create Oauth Credentials
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
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
kongClient
  .refreshAccessToken({
    refreshToken: 'refresh_token',
    clientId: 'clientId',
    clientSecret: 'clientSecret'
  })
  .then(res => console.log(res))

Keywords