Client to obtain tokens for service to service calls
Last updated 2 years ago by jenkins-reform-hmcts .
MIT · Original npm · Tarball · package.json
$ cnpm install @hmcts/div-service-auth-provider-client 
SYNC missed versions from official npm registry.

Client library for service-auth-provider service

Client library to obtain service to service call tokens.


  • Node >=8.0
  • yarn


As of now, this module is published only in a private repository. We are working on publishing this project to NPM. Until then, the package can be installed from its github URL, examples:

# Install the latest version
yarn add https://github.com/hmcts/div-service-auht-provider-client

# Install a specific version
yarn add https://github.com/hmcts/div-service-auth-provider-client#2.1.4


First get a client

const serviceAuthProviderClient = require('@hmcts/div-service-auth-provider-client')

const client = serviceAuthProviderClient.init({
  apiBaseUrl: 'https://service-auth-provider-api:4502', // Base URL of service-auth-provider API
  microservice: 'reference', // The name of the IDAM service role
  secret: 'AAAAAAAAAAAAAAAA' // Service secret

Obtain a token

  .then(token => {
    // The response payload contains the token in plain text.
  .catch(err => {
    // Or an error in case of an error.

Check if a token is expired

client.isTokenExpired(token) // true if expired, false otherwise.

Implementation notes

Token expiry

Tokens returned contain an expiry date as a unix timestamp under exp. Ideally, this expiry date should be respected and the token should be renewed using the lease method.

Service secrets

The service needs to be registered with IDAM and a secret is required in order to generate a token.

For early implementations where IDAM registration has not finished yet, the reference details (microservice, secret) can be used from the above example.

Current Tags

  • 3.0.1                                ...           latest (2 years ago)

1 Versions

  • 3.0.1                                ...           2 years ago
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 3
Dependencies (4)
Dev Dependencies (10)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |