code: private synchronized void fetchCredentials() {
          if (!needsToLoadCredentials()) return;
  
          JsonNode accessKey;
          JsonNode secretKey;
          JsonNode node;
          JsonNode token;
          try {
              lastInstanceProfileCheck = new Date();
  
              String credentialsResponse = EC2CredentialsUtils.getInstance().readResource(credentailsEndpointProvider.getCredentialsEndpoint(), credentailsEndpointProvider.getRetryPolicy());
  
              node = Jackson.jsonNodeOf(credentialsResponse);
              accessKey = node.get(ACCESS_KEY_ID);
              secretKey = node.get(SECRET_ACCESS_KEY);
              token = node.get(TOKEN);
  
              if (null == accessKey || null == secretKey) {
                  throw new SdkClientException("Unable to load credentials.");
              }
  
              if (null != token) {
                  credentials = new BasicSessionCredentials(accessKey.asText(),
                          secretKey.asText(), token.asText());
              } else {
                  credentials = new BasicAWSCredentials(accessKey.asText(),
                          secretKey.asText());
              }
  
              JsonNode expirationJsonNode = node.get("Expiration");
              if (null != expirationJsonNode) {
                  /*
                   * TODO: The expiration string comes in a different format
                   * than what we deal with in other parts of the SDK, so we
                   * have to convert it to the ISO8601 syntax we expect.
                   */
                  String expiration = expirationJsonNode.asText();
                  expiration = expiration.replaceAll("\\+0000$", "Z");
  
                  try {
                      credentialsExpiration = DateUtils.parseISO8601Date(expiration);
                  } catch(Exception ex) {
                      handleError("Unable to parse credentials expiration date from Amazon EC2 instance", ex);
                  }
              }
          } catch (JsonMappingException e) {
              handleError("Unable to parse response returned from service endpoint", e);
          } catch (IOException e) {
              handleError("Unable to load credentials from service endpoint", e);
          } catch (URISyntaxException e) {
              handleError("Unable to load credentials from service endpoint", e);
          }
      }
docs: Fetches the credentials from the endpoint.