Skip to content

devit-tel/kong-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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))

About

Kong utility function

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published