Doubts about how to authenticate to Amazon S3 with an Amazon Cognito IDENTITY_POOL_ID with Java SDK

Viewed 183

I am doing a small Java project (not Android) that is used to load files into an Amazon S3 bucket and everything has been loaded correctly as follows:

private BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials("secrey-key", "access-key");
private final AmazonS3 s3Client = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(basicAWSCredentials)).withRegion(Regions.REGION_U_KNOW).build();
s3Client.putObject("bucket-name", "concat-path", new File("path"));

But now I have to do the authentication through a Cognito IDENTITY_POOL_ID, and according to what I see in the documentation it is done through the class:AmazonCognitoIdentityClientBuilder

In this class there is a method called: getCredentials() and this method can return an object of type AWSCredentialsProvider.

Can someone help me understand all this and how to upload my files to the bucket with the credentials that I get from AmazonCognitoIdentityClientBuilder and my IDENTITY_POOL_ID? Please

0 Answers
Related