Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

438
Views
Error: Missing credentials in config - /nodeapp/node_modules/aws-sdk/lib/request.js:31

I'm pulling objects using s3.listObjects() function from the AWS-SDK and I keep getting the following error:

/nodeapp/node_modules/aws-sdk/lib/request.js:31 

Followed by

Error: Missing credentials in config
at IncomingMessage.<anonymous> (/nodeapp/node_modules/aws-sdk/lib/util.js:863:34)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:186:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)

This doesn't add up because I have a different route (downloadParam) that retrieves an object from S3 without giving me this error. Additionally, when I log out the objects retrieved from downloadResults route, it appears the objects were retrieved with no issues but i'll still get this error.

I have spent hours on this issue and I can't seem to figure out why this is occurring. I have pasted by code for both routes below, the one that works and the one that doesn't. From what I've gleaned online, this appears to be more of a code issue than an AWS-SDK credentials issue.

  downloadParam: function(app, s3){
app.use('/api', apiRoutes)

apiRoutes.get('/download-param-file', function(req, res, next){
 res.set({'Content-Type':'text/csv'})
  s3.getObject({Bucket: 'some-bucket', Key: 'some-key' + req.query.fileName}, function(err, file){

    if (err) {
      console.log(err);
      return next(err);
    } else {
      return res.send(file.Body.toString());
    }
  })
})
},

downloadResults: function(app, s3){
app.use('/api', apiRoutes)

apiRoutes.get('/download-results-file', function(req, res, next){
   res.set({'Content-type': 'application/zip'})

   var params = {
    Bucket: 'some-bucket',
    Delimiter: '/',
    Prefix: 'some-key'
    };


   var filesArray = []
   var files = s3.listObjects(params).createReadStream()
   var xml = new XmlStream(files)
   xml.collect('Key')

   xml.on('endElement: Key', function(item) {
     filesArray.push(item['$text'].substr(params.Prefix.length))
    })

   xml.on('end', function() {

    res.send(zip(filesArray, req.query.jobName,  params))


  })        
})
}

As of right now downloadParams works as expected but downloadResults does not. Any help would be tremendously appreciated.

This link seems solve an issue similar to mine

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You're not authenticating the call. The bucket does not have permissions to list objects without authentication, whereas it does have permission to download specific files without authentication.

See the Amazon Documentation on adding credentials safely to the instance.

Essentially,

var creds = AWS.Credentials();
creds.accessKeyId = 'AKIAIOSFODNN7EXAMPLE';
creds.secretAccessKey = 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY';

AWS.config.credentials = creds;
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!