/axios-keycloak

🔑 Keycloak client with build in axios functionality

Primary LanguageJavaScriptMIT LicenseMIT

axios-keycloak npm version Build Status

Keycloak client with build in axios functionality, letting you create axios instances for doing authenticated request. The module is dealing with the token refresh for you.

Usage

import AxiosKeycloak from 'axios-keycloak'

...

const kc = new AxiosKeycloak()
const axiosInstance = kc.createAxiosInstance()

kc.init({ onLoad: 'login-required' })
  .then(() => {
    // authenticated request using keycloak access token
    return axiosInstance.get('/user/12345')
  })
  .then((response) => {
    // ...
  }

// In case you want do an unauthenticated request
const axios = AxiosKeycloak.axios