Skip to content

Commit 05ef493

Browse files
author
Dushyant Bhalgami
authored
Merge pull request #4 from topcoder-platform/feature/auth0-proxy-server
m2m token through auth0 proxy server.
2 parents ca10765 + db1b5b9 commit 05ef493

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ module.exports = (config) => {
1212
AUTH0_CLIENT_ID: joi.string().required(),
1313
AUTH0_CLIENT_SECRET: joi.string().required(),
1414
BUSAPI_URL: joi.string().uri().trim().required(),
15-
KAFKA_ERROR_TOPIC: joi.string().required()
15+
KAFKA_ERROR_TOPIC: joi.string().required(),
16+
AUTH0_PROXY_SERVER_URL: joi.string()
1617
})
1718

1819
// Validate the arguments

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"joi": "^13.4.0",
1414
"lodash": "^4.17.10",
1515
"superagent": "^3.8.3",
16-
"tc-core-library-js": "appirio-tech/tc-core-library-js.git#feature/m2mtoken"
16+
"tc-core-library-js": "appirio-tech/tc-core-library-js.git#v2.6"
1717
},
1818
"devDependencies": {
1919
"chai": "^4.2.0",

src/common/helper.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
const m2mAuth = require('tc-core-library-js').auth.m2m
33
const request = require('superagent')
44
const _ = require('lodash')
5+
var m2m = null
56

67
/*
78
* Function to get M2M token
89
* @returns {Promise}
910
*/
1011
const getM2Mtoken = async (config) => {
11-
const m2m = m2mAuth(_.pick(config, ['AUTH0_URL', 'AUTH0_AUDIENCE', 'TOKEN_CACHE_TIME']))
12+
if (_.isNull(m2m)) {
13+
m2m = m2mAuth(_.pick(config, ['AUTH0_URL', 'AUTH0_AUDIENCE', 'TOKEN_CACHE_TIME', 'AUTH0_PROXY_SERVER_URL']))
14+
}
1215
return m2m.getMachineToken(config.AUTH0_CLIENT_ID, config.AUTH0_CLIENT_SECRET)
1316
}
1417

0 commit comments

Comments
 (0)