aws-samples / amazon-textract-searchable-pdf

Generate searchable pdf documents from scanned documents with Amazon Textract
Other
65 stars 27 forks source link

Unable to find a region via the region provider chain #1

Closed sneiderV closed 4 years ago

sneiderV commented 4 years ago

Hi, I'm interested in using textrack and I read the instructions mentioned in the main page of Amazon like those of this repository.

I am using the class: DemoPdfFromLocalPdf.java But I get the following error when run application:

com.amazonaws.SdkClientException: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region. at com.amazonaws.client.builder.AwsClientBuilder.setRegion(AwsClientBuilder.java:462) at com.amazonaws.client.builder.AwsClientBuilder.configureMutableProperties(AwsClientBuilder.java:424) at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46) at com.amazonaws.services.textract.AmazonTextractClientBuilder.defaultClient(AmazonTextractClientBuilder.java:45) at DemoPdfFromLocalPdf.extractText(DemoPdfFromLocalPdf.java:28) at DemoPdfFromLocalPdf.run(DemoPdfFromLocalPdf.java:73) at Demo.main(Demo.java:10)

I try to use in this class (DemoPdfFromLocalPdf.java) the method .withRegion to set it:

AmazonTextractClientBuilder client = AmazonTextractClientBuilder.standard().withRegion(Regions.US_EAST_1); but, show the same error.

finally, use the .isServiceSupported method to know in which Region the service was available, use all regions (21 Regions) but always throw me false in the response. Maybe the service is not hosted in any region, to make free use? System.out.println("isSupported: "+Region.getRegion(Regions.EU_CENTRAL_1).isServiceSupported(AmazonTextract.ENDPOINT_PREFIX));

any idea of this?

Thank you.

darwaishx commented 4 years ago

Do you have AWS CLI setup with default region? See link below for more details: https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/setup-credentials.html

galdino commented 4 years ago

Hi , I have had the same problem too. Reading in this page about "Explicitly Specifying Credentials", I have tried to do the same in this class: DemoPdfFromLocalPdf.java

Firstly, I have created my "access_key_id" and "secret_key_id" following this.

Then, I have altered the class (DemoPdfFromLocalPdf.java) this way:

BasicAWSCredentials awsCreds = new BasicAWSCredentials("access_key_id", "secret_key_id");
AmazonTextract client = AmazonTextractClientBuilder
                                .standard()
                                .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
                                .withRegion(Regions.US_EAST_1)
                                .build();

So far, it works for me!

lssindhuri commented 4 years ago

HI, i tried above method but i am getting below error. I just created the access_key_id and secret_key_id com.amazonaws.services.textract.model.AmazonTextractException: The security token included in the request is invalid. (Service: AmazonTextract; Status Code: 400; Error Code: UnrecognizedClientException;