title: com.amazonaws.services.s3.model.AmazonS3Exception: Access Denied
body: <p>Here's my Java code:</p>
  
  <pre><code>        AmazonS3 conn = new AmazonS3Client();
          AmazonS3URI uri = new AmazonS3URI(s3uri);
          ObjectListing objects = conn.listObjects(uri.getBucket(), uri.getKey());
  </code></pre>
  
  <p>A very simple task, I try to use AmazonS3 Java client to access S3, but this line <code>conn.listObjects</code> keeps failing and gave me the following exception:</p>
  
  <pre><code>Exception in thread "main" com.amazonaws.services.s3.model.AmazonS3Exception: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: XXXXXXXX), S3 Extended Request ID: xxxxxxxxx
      at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1389)
      at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:902)
      at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:607)
      at com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:376)
      at com.amazonaws.http.AmazonHttpClient.executeWithTimer(AmazonHttpClient.java:338)
      at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:287)
      at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3826)
      at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3778)
      at com.amazonaws.services.s3.AmazonS3Client.listObjects(AmazonS3Client.java:610)
      at com.amazonaws.services.s3.AmazonS3Client.listObjects(AmazonS3Client.java:588)
  </code></pre>
  
  <ol>
  <li><p>A very obvious error code: 403 which denotes my aws credentials are wrong, however, this is exactly the same credentials that my coworkers are using to access the same s3 bucket, to rule out the possibility that I have a typo somewhere, I literally deleted my previous one and used the same one that my coworkers sent to me and put them under ~/.aws/</p></li>
  <li><p>I also researched other possible reasons, one could be that this S3 bucket doesn't give the permissions to my IAM role, apparently that is not be my case either.</p></li>
  </ol>
  
  <p>Any help please?
  What could be the culprit?</p>