code: public static void obtainAndCache(RestClient client, User user) throws IOException {
          EsToken token = obtainEsToken(client, user);
  
          if (token == null) {
              throw new IOException("No token returned for user " + user.getKerberosPrincipal().getName());
          }
          if (LOG.isDebugEnabled()) {
              LOG.debug("Obtained token " + EsTokenIdentifier.KIND_NAME + " for user " +
                      user.getKerberosPrincipal().getName());
          }
          user.addEsToken(token);
      }
docs: Obtain an authentication token for the given user and add it to the
  user's credentials.
  @param client The Elasticsearch client
  @param user The user for obtaining and storing the token
  @throws IOException If making a remote call to the authentication service fails