diff --git a/lib/config/index.js b/lib/config/index.js index d5f566a1af10af4f2385ae8d09314d1f82a21515..6a474348e04d93ba50dbbe4281c9e01818ce5eae 100644 --- a/lib/config/index.js +++ b/lib/config/index.js @@ -89,15 +89,15 @@ async function parseConfigs(env, argv) { } const endpoint = config.endpoint || platformInfo.endpoint; let token = config.token; + if (username && password) { + logger.info('Using username and password to generate token'); + const base64 = str => Buffer.from(str, 'binary').toString('base64'); + token = base64(`${username}:${password}`); + } if (!token) { - if (username && password) { - const base64 = str => Buffer.from(str, 'binary').toString('base64'); - token = base64(`${username}:${password}`); - } else { - throw new Error( - `No authentication found for platform ${endpoint} (${platform})` - ); - } + throw new Error( + `No authentication found for platform ${endpoint} (${platform})` + ); } config.hostRules.push({ platform,