diff --git a/src/storage/s3.js b/src/storage/s3.js index bb8541d4c..a28d6ef7c 100644 --- a/src/storage/s3.js +++ b/src/storage/s3.js @@ -52,9 +52,11 @@ function getCaasCredentials(apiConfig, callback) { assert(apiConfig.token); if ((new Date() - gCachedCaasCredentials.issueDate) <= (1.75 * 60 * 60 * 1000)) { // caas gives tokens with 2 hour limit - return gCachedCaasCredentials.credentials; + return callback(null, gCachedCaasCredentials.credentials); } + debug('getCaasCredentials: getting new credentials'); + var url = config.apiServerOrigin() + '/api/v1/boxes/' + config.fqdn() + '/awscredentials'; superagent.post(url).query({ token: apiConfig.token }).timeout(30 * 1000).end(function (error, result) { if (error && !error.response) return callback(error);