1.0.2 • Published 4 years ago
action-platform-auth v1.0.2
Action Platform Auth Library
This library is useful to fetch Azure AD access tokens for Action Platform APIs from NodeJS command line.
Getting Started
- Clone the repo
- Navigate to the repo root
npm install
- to run tests
npm test
Installation
npm install --save action-platform-auth
Usage
Include
const actionAuth = require('action-platform-auth');
Using promise
actionAuth.fetchToken(actionAuth.TokenScope.PackageReadWriteAll)
.then(tokenResponse => {
console.log(`token - ${tokenResponse.token}`);
console.log(`expiresIn - ${tokenResponse.expiresIn}`);
})
.catch(errorResponse => {
console.log(`errorCode - ${errorResponse.errorCode}`);
console.log(`errorMessage - ${errorResponse.errorMessage}`);
});
Using async/await
try {
var tokenResponse = await actionAuth.fetchToken(actionAuth.TokenScope.PackageReadWriteAll);
console.log(`token - ${tokenResponse.token}`);
console.log(`expiresIn - ${tokenResponse.expiresIn}`);
} catch (errorResponse) {
console.log(`errorCode - ${errorResponse.errorCode}`);
console.log(`errorMessage - ${errorResponse.errorMessage}`);
}