title: Unable to load credentials from any of the providers in the chain AwsCredentialsProviderChain
body: <p>I'm getting the following exception when trying to read a file to AWS S3 Error:</p>
  <blockquote>
  <p>Unable to load AWS credentials from any provider in the chain.</p>
  </blockquote>
  <p>I have generated a public bucket and also generated an AWS IAM role with full S3 bucket access and textract access.</p>
  <p>I am trying to read an image from S3 bucket and run AWS Textract service.</p>
  <p>Java code:</p>
  <pre class="lang-java prettyprint-override"><code>package com.textract;
  
  import com.amazonaws.auth.AWSStaticCredentialsProvider;
  import com.amazonaws.auth.BasicAWSCredentials;
  import com.amazonaws.services.s3.AmazonS3;
  import com.amazonaws.services.s3.AmazonS3Client;
  import com.amazonaws.services.s3.AmazonS3ClientBuilder;
  import com.amazonaws.services.s3.model.S3Object;
  import com.amazonaws.services.s3.model.S3ObjectInputStream;
  import software.amazon.awssdk.core.SdkBytes;
  import software.amazon.awssdk.regions.Region;
  import software.amazon.awssdk.services.textract.TextractClient;
  import software.amazon.awssdk.services.textract.model.*;
  
  import java.util.ArrayList;
  import java.util.LinkedHashMap;
  import java.util.List;
  import java.util.Map;
  
  
  public class App {
  
      public static Map&lt;String, String&gt; getRelationships(Map&lt;String, Block&gt; blockMap, Map&lt;String, Block&gt; keyMap,Map&lt;String, Block&gt; valueMap) {
          Map&lt;String, String&gt; result = new LinkedHashMap&lt;&gt;();
          for(Map.Entry&lt;String, Block&gt; itr : keyMap.entrySet()) {
              Block valueBlock = findValue(itr.getValue(), valueMap);
              String key = getText(itr.getValue(), blockMap);
              String value = getText(valueBlock, blockMap);
              result.put(key, value);
          }
          return result;
      }
  
      public static Block findValue(Block keyBlock, Map&lt;String, Block&gt; valueMap) {
          Block b = null;
          for(Relationship relationship : keyBlock.relationships()) {
              if(relationship.type().toString().equals(&quot;VALUE&quot;)) {
                  for(String id : relationship.ids()) {
                      b = valueMap.get(id);
                  }
              }
          }
          return b;
      }
  
      public static String getText(Block result, Map&lt;String, Block&gt; blockMap) {
          StringBuilder stringBuilder = new StringBuilder();
          for(Relationship relationship : result.relationships()) {
              if(relationship.type().toString().equals(&quot;CHILD&quot;)) {
                  for(String id : relationship.ids()) {
                      Block b = blockMap.get(id);
                      if(b.blockTypeAsString().equals(&quot;WORD&quot;)) {
                          stringBuilder.append(b.text()).append(&quot; &quot;);
                      }
                   }
              }
          }
          return stringBuilder.toString();
      }
  
      public static void main(String[] args) {
          
          BasicAWSCredentials creds = new BasicAWSCredentials(&quot;&lt;Secret Key&gt;&quot;, &quot;&lt;Access Key&gt;&quot;);
          AmazonS3 s3client = AmazonS3Client.builder()
                  .withRegion(&quot;ap-southeast-1&quot;)
                  .withCredentials(new AWSStaticCredentialsProvider(creds))
                  .build();
          
  //        AmazonS3 s3client = AmazonS3ClientBuilder.standard().build();
          S3Object s3Object = s3client.getObject(&quot;&lt;S3 Bucket&gt;&quot;, &quot;image.jpg&quot;);
          S3ObjectInputStream s3ObjectInputStream = s3Object.getObjectContent();
  
          SdkBytes bytes = SdkBytes.fromInputStream(s3ObjectInputStream);
          Document doc = Document.builder().bytes(bytes).build();
  
          List&lt;FeatureType&gt; list = new ArrayList&lt;&gt;();
          list.add(FeatureType.FORMS);
  
          AnalyzeDocumentRequest request = AnalyzeDocumentRequest.builder().featureTypes(list).document(doc).build();
  
          TextractClient textractClient = TextractClient.builder().region(Region.US_WEST_2).build();
  
          AnalyzeDocumentResponse response = textractClient.analyzeDocument(request);
          List&lt;Block&gt; blocks = response.blocks();
  
          Map&lt;String, Block&gt; blockMap = new LinkedHashMap&lt;&gt;();
          Map&lt;String, Block&gt; keyMap = new LinkedHashMap&lt;&gt;();
          Map&lt;String, Block&gt; valueMap = new LinkedHashMap&lt;&gt;();
  
          for (Block b : blocks) {
              String block_id = b.id();
              blockMap.put(block_id, b);
              if(b.blockTypeAsString().equals(&quot;KEY_VALUE_SET&quot;)) {
                  for(EntityType entityType : b.entityTypes()) {
                      if(entityType.toString().equals(&quot;KEY&quot;)) {
                          keyMap.put(block_id, b);
                      } else {
                          valueMap.put(block_id, b);
                      }
                  }
              }
          }
              System.out.println(getRelationships(blockMap, keyMap, valueMap));
              textractClient.close();
  
      }
  }
  </code></pre>
  <p>Console error:</p>
  <pre class="lang-none prettyprint-override"><code>SLF4J: Failed to load class &quot;org.slf4j.impl.StaticLoggerBinder&quot;.
  SLF4J: Defaulting to no-operation (NOP) logger implementation
  SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
  Exception in thread &quot;main&quot; software.amazon.awssdk.core.exception.SdkClientException: Unable to load credentials from any of the providers in the chain AwsCredentialsProviderChain(credentialsProviders=[SystemPropertyCredentialsProvider(), EnvironmentVariableCredentialsProvider(), WebIdentityTokenCredentialsProvider(), ProfileCredentialsProvider(), ContainerCredentialsProvider(), InstanceProfileCredentialsProvider()]) : [SystemPropertyCredentialsProvider(): Unable to load credentials from system settings. Access key must be specified either via environment variable (AWS_ACCESS_KEY_ID) or system property (aws.accessKeyId)., EnvironmentVariableCredentialsProvider(): Unable to load credentials from system settings. Access key must be specified either via environment variable (AWS_ACCESS_KEY_ID) or system property (aws.accessKeyId)., WebIdentityTokenCredentialsProvider(): Either the environment variable AWS_WEB_IDENTITY_TOKEN_FILE or the javaproperty aws.webIdentityTokenFile must be set., ProfileCredentialsProvider(): Profile file contained no credentials for profile 'default': ProfileFile(profiles=[]), ContainerCredentialsProvider(): Cannot fetch credentials from container - neither AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI environment variables are set., InstanceProfileCredentialsProvider(): Unable to load credentials from service endpoint.]
      at software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:98)
      at software.amazon.awssdk.auth.credentials.AwsCredentialsProviderChain.resolveCredentials(AwsCredentialsProviderChain.java:112)
      at software.amazon.awssdk.auth.credentials.internal.LazyAwsCredentialsProvider.resolveCredentials(LazyAwsCredentialsProvider.java:45)
      at software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider.resolveCredentials(DefaultCredentialsProvider.java:104)
      at software.amazon.awssdk.awscore.client.handler.AwsClientHandlerUtils.createExecutionContext(AwsClientHandlerUtils.java:76)
      at software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler.createExecutionContext(AwsSyncClientHandler.java:68)
      at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.lambda$execute$1(BaseSyncClientHandler.java:97)
      at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.measureApiCallSuccess(BaseSyncClientHandler.java:167)
      at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:94)
      at software.amazon.awssdk.core.client.handler.SdkSyncClientHandler.execute(SdkSyncClientHandler.java:45)
      at software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler.execute(AwsSyncClientHandler.java:55)
      at software.amazon.awssdk.services.textract.DefaultTextractClient.analyzeDocument(DefaultTextractClient.java:215)
      at com.textract.App.main(App.java:83)
  </code></pre>