Helper library to handle IBM Cloud IAM Tokens


stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
38May 29, 2021Aug 16, 2018Minified + gzip package size for @ibm-functions/iam-token-manager in KB


IBM IAM Token Manager library

Build Status License JavaScript Style Guide


npm install @ibm-functions/iam-token-manager


Provide constructor parameters iamApikey and iamUrl (Optional) to create a new instance.

const itm = require('@ibm-functions/iam-token-manager')
const m = new itm({

Use the function getToken to get an IAM acess token. This function returns a Promise.

m.getToken().then(token => console.log('Authorization:', 'Bearer', token))


Authorization: Bearer eyJhbGciOiJIUz......sgrKIi8hdFs

Use the function getAuthHeader to get a Bearer HTTP Authorization header including the token. This function returns a Promise.

m.getAuthHeader().then(header => console.log('Authorization:', header))


Authorization: Bearer eyJhbGciOiJIUz......sgrKIi8hdFs

Using with OpenWhisk client library

const itm = require('@ibm-functions/iam-token-manager')
const m = new itm({
const openwhisk = require('openwhisk')
const ow = openwhisk({

Note: Need to use a version of openwhisk that supports auth_handler plugin.

Using Within IBM Cloud Functions nodejs v8 runtime

The nodejs v8 runtime provides an openwhisk npm module already including the iam token manager plugin pre-installed, it will use the environment variable __OW_IAM_NAMESPACE_API_KEY as the iamApikey

var openwhisk = require('openwhisk');

function action() {
  var ow = openwhisk();
  return ow.actions.invoke('sample')

exports.main = action



If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.