UNPKG

xmtoolbox

Version:

A Node JS package for interacting with xMatters. Contains functions to interact with xMatters APIs or perform a synchronization, create events, libraries to convert data, and much much more!

38 lines (33 loc) 1.38 kB
const common = require('./common'); /** * A module related to xMatters oauth.<br><br> * {@link https://help.xmatters.com/xmapi/index.html#oauth} * * @module oauth */ /** * Get an oauth access token in xMatters<br><br> * * {@link https://help.xmatters.com/xmapi/index.html#obtain-an-access-token-and-refresh-token} * * @param {module:environments.xMattersEnvironment} env The xmtoolbox representation of an xMatters instance. * @param {Object} query A json object representing the query string parameters for this request. * @returns {Promise<AccessToken>} AccessToken Object Requested */ async function getToken(env, query) { return common.request(env, `/api/xm/1/oauth2/token`, query, { method: 'POST' }, 'Get Oauth2 Token'); } /** * Refresh the oauth token in xMatters<br><br> * * {@link https://help.xmatters.com/xmapi/index.html#refresh-an-access-token} * * @param {module:environments.xMattersEnvironment} env The xmtoolbox representation of an xMatters instance. * @param {Object} query A json object representing the query string parameters for this request. * @returns {Promise<AccessToken>} AccessToken Object Requested */ async function refreshToken(env, query) { return common.request(env, `/api/xm/1/oauth2/token`, query, { method: 'POST' }, 'Refresh Oauth2 Token'); } exports.getToken = getToken; exports.refreshToken = refreshToken;