0

I am trying to establish connection to aws for perofrming basic operations on s3 bucket. Following is the code:

def list(){
        AWSCredentials credentials = new BasicAWSCredentials("Access key", "Secret Key");


        AmazonS3 s3client = new AmazonS3Client(credentials);


        String bucketName = "sample-bucket-from-java-code";



        System.out.println("Listing all buckets : ");
        for (Bucket bucket : s3client.listBuckets()) {
            System.out.println(" - " + bucket.getName());
        }
    }

This gives me the error:

request- Received error response: com.amazonaws.services.s3.model.AmazonS3Exception: The request signature we calculated does not match the signature you provided. Check your key and signing method.

I have also double checked the access key and secret key that I am using. Cannot figure out the issue.

Anshul Verma
  • 1,065
  • 1
  • 9
  • 26
  • did you check http://stackoverflow.com/questions/2777078/amazon-mws-request-signature-calculated-does-not-match-the-signature-provided – Frederic Henri Apr 25 '16 at 07:20

1 Answers1

-1

Its always good to use "cognito accountId" rather than access and secret key. Because using cognito accountID has limited access to AWS, which can always be changed.

// Initialize the Amazon Cognito credentials provider.

AWSCognitoCredentialsProvider* credentialsProvider = [AWSCognitoCredentialsProvider
                                                      credentialsWithRegionType:AWSRegionUSEast1
                                                      accountId:@"xxxxxxxxxxx"
                                                      identityPoolId:@"xxxxxxxxxxx"
                                                      unauthRoleArn:@"arn:aws:iam::xxxxxxxxxxx"
                                                      authRoleArn:nil];

AWSServiceConfiguration* configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSWest2
                                                                      credentialsProvider:credentialsProvider];

[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;

You can also find running code from my blog.

https://tauheeda.wordpress.com/2015/10/15/use-aws-service-to-downloadupload-files-in-your-applications/

Do not forget to add your credential info:

accountId:@“xxxxxxxx” identityPoolId:@”xxxxxxxx-xxxxxxxx” unauthRoleArn:@”xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx“

tauheed
  • 161
  • 1
  • 12