diff --git a/lib/npm-info.js b/lib/npm-info.js index b861796d..24a10734 100644 --- a/lib/npm-info.js +++ b/lib/npm-info.js @@ -10,12 +10,16 @@ module.exports = function (pkgName, cb) { npmconf.load, function (conf, callback) { var cred = conf.getCredentialsByURI(registry) - callback(null, { + var reqopts = { url: registry + pkgName.replace(/\//g, '%2F'), - headers: { - 'Authorization': cred.token ? 'Bearer ' + cred.token : null - } - }) + headers: {} + } + if (cred.token) { + reqopts.headers.Authorization = 'Bearer ' + cred.token + } else if (cred.auth) { + reqopts.headers.Authorization = 'Basic ' + cred.auth + } + callback(null, reqopts) }, request, function (response, body, callback) {