Aws-sdk-js: Javascript SDK has no anonymous way to call S3 APIs

Created on 18 Dec 2013  路  3Comments  路  Source: aws/aws-sdk-js

Some S3 API can be called without being authenticated.
GetObject and ListObject are valid example on public buckets

When using code such as

    var s3 = new AWS.S3();
    s3.listObjects(params = {Bucket: bucketName, Prefix: prefix }, function (err, data) { ... })

I do receive

Error : "SigningError"
message: "Missing credentials in config"

we would need a way to make anonymous queries for AWS.S3 object

feature-request

Most helpful comment

I've publicly exposed the internal makeUnauthenticatedRequest operation we use for some unauthenticated operations, which you will be able to use in the next release of the SDK (you can already use this in the current SDK). See the above commit for a usage example.

All 3 comments

You can do this by removing the signing and credential validation handlers:

function unauthenticatedRequest(operation, params, callback) {
  var request = s3[operation](params);
  request.removeListener('validate', AWS.EventListeners.Core.VALIDATE_CREDENTIALS);
  request.removeListener('sign', AWS.EventListeners.Core.SIGN);
  request.send(callback);
}

unauthenticatedRequest('listObjects', {Bucket: 'mybucket'}, function (err, data) { ... });

As for an unsigned getObject, you can just use a regular http GET to download public objects from S3.

I've publicly exposed the internal makeUnauthenticatedRequest operation we use for some unauthenticated operations, which you will be able to use in the next release of the SDK (you can already use this in the current SDK). See the above commit for a usage example.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

Was this page helpful?
0 / 5 - 0 ratings