Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ibm-functions/iam-token-manager

Package Overview
Dependencies
Maintainers
7
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ibm-functions/iam-token-manager

Helper library to handle IBM Cloud IAM Tokens

  • 1.0.11
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
142
increased by43.43%
Maintainers
7
Weekly downloads
 
Created
Source

IBM IAM Token Manager library

Build Status License JavaScript Style Guide

Installation

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

Usage

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

const itm = require('@ibm-functions/iam-token-manager')
const m = new itm({
    "iamApikey":"1234ABCD..."
})

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

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

output:

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

output:

Authorization: Bearer eyJhbGciOiJIUz......sgrKIi8hdFs

Using with OpenWhisk client library

const itm = require('@ibm-functions/iam-token-manager')
const m = new itm({
    "iamApikey":"1234ABCD..."
})
const openwhisk = require('openwhisk')
const ow = openwhisk({
    auth_handler:m
})

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

License

Apache-2.0

FAQs

Package last updated on 07 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc