java - AWS S3 using grails -
i trying establish connection aws perofrming basic operations on s3 bucket. following 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 buckets : "); (bucket bucket : s3client.listbuckets()) { system.out.println(" - " + bucket.getname()); } }
this gives me error:
request- received error response: com.amazonaws.services.s3.model.amazons3exception: request signature calculated not match signature provided. check key , signing method.
i have double checked access key , secret key using. cannot figure out issue.
its use "cognito accountid" rather access , secret key. because using cognito accountid has limited access aws, can changed.
// initialize 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 find running code blog.
do not forget add credential info:
accountid:@“xxxxxxxx” identitypoolid:@”xxxxxxxx-xxxxxxxx” unauthrolearn:@”xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx“
Comments
Post a Comment