predix-uaa-client
Node module to get a token from UAA using client credentials or a refresh token.
Usage
Install via npm
npm install --save predix-uaa-client
This package can be used in various ways, depending on the params passed into the getToken
function.
Use client credentials to get a bearer token.
In this mode, no refresh token is passed in. This call can be made for each outgoing request. The library will cache the token until expiry, so subsequent calls will resolve instantaneously.
const uaa_util = ;// Call with client credentials (UAAUrl, ClientID, ClientSecret),// will fetch a client token using these credentials.// In this case the client needs authorized_grant_types: client_credentialsuaa_util;
Use a refresh token get a new access_token for a user.
When passing a refresh token, the function will NOT cache, this should only be called when a new user access token is required.
const uaa_util = ;// Call with client credentials (UAAUrl, ClientID, ClientSecret, RefreshToken),// will fetch an access token for the user represented by the refresh token.// In this case the client needs authorized_grant_types: refresh_tokenuaa_util;
Request scopes if a token with particular scopes (ex. authZ permisions) is required.
The 5th parameter is passed as a comma separated string of scopes.
const uaa_util = ;// Call with client credentials (UAAUrl, ClientID, ClientSecret, null, scopes),// will fetch an access token for the user with requested scopes.// In this case the client needs authorized_grant_types: refresh_tokenuaa_util;