diff --git a/index.js b/index.js index eabb21c..f746a19 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,8 @@ module.exports = (config) => { AUTH0_CLIENT_ID: joi.string().required(), AUTH0_CLIENT_SECRET: joi.string().required(), BUSAPI_URL: joi.string().uri().trim().required(), - KAFKA_ERROR_TOPIC: joi.string().required() + KAFKA_ERROR_TOPIC: joi.string().required(), + AUTH0_PROXY_SERVER_URL: joi.string() }) // Validate the arguments diff --git a/package.json b/package.json index 43d1dfa..6b13fb2 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "joi": "^13.4.0", "lodash": "^4.17.10", "superagent": "^3.8.3", - "tc-core-library-js": "appirio-tech/tc-core-library-js.git#feature/m2mtoken" + "tc-core-library-js": "appirio-tech/tc-core-library-js.git#v2.6" }, "devDependencies": { "chai": "^4.2.0", diff --git a/src/common/helper.js b/src/common/helper.js index ddea845..5c0b013 100644 --- a/src/common/helper.js +++ b/src/common/helper.js @@ -2,13 +2,16 @@ const m2mAuth = require('tc-core-library-js').auth.m2m const request = require('superagent') const _ = require('lodash') +var m2m = null /* * Function to get M2M token * @returns {Promise} */ const getM2Mtoken = async (config) => { - const m2m = m2mAuth(_.pick(config, ['AUTH0_URL', 'AUTH0_AUDIENCE', 'TOKEN_CACHE_TIME'])) + if (_.isNull(m2m)) { + m2m = m2mAuth(_.pick(config, ['AUTH0_URL', 'AUTH0_AUDIENCE', 'TOKEN_CACHE_TIME', 'AUTH0_PROXY_SERVER_URL'])) + } return m2m.getMachineToken(config.AUTH0_CLIENT_ID, config.AUTH0_CLIENT_SECRET) }