Menu
Amazon Simple Storage Service
Developer Guide (API Version 2006-03-01)

Making Requests Using AWS Account or IAM User Credentials - AWS SDK for Java

The following tasks guide you through using the Java classes to send authenticated requests using your AWS account credentials or IAM user credentials.

Making Requests Using Your AWS account or IAM user credentials

1

Create an instance of the AmazonS3Client class.

2

Execute one of the AmazonS3Client methods to send requests to Amazon S3. The client generates the necessary signature value from your credentials and includes it in the request it sends to Amazon S3.


The following Java code sample demonstrates the preceding tasks.

AmazonS3 s3client = new AmazonS3Client(new ProfileCredentialsProvider());        

// Send sample request (list objects in a given bucket).
ObjectListing objectListing = s3client.listObjects(new 
     ListObjectsRequest().withBucketName(bucketName));

Note

You can create the AmazonS3Client class without providing your security credentials. Requests sent using this client are anonymous requests, without a signature. Amazon S3 returns an error if you send anonymous requests for a resource that is not publicly available.

To see how to make requests using your AWS credentials within the context of an example of listing all the object keys in your bucket, see Listing Keys Using the AWS SDK for Java. For more examples, see Working with Amazon S3 Objects and Working with Amazon S3 Buckets. You can test these examples using your AWS Account or IAM user credentials.