code: private static Token<DelegationTokenIdentifier> fetchHcatToken(final String userToProxy, final HiveConf hiveConf,
        final String tokenSignatureOverwrite, final IMetaStoreClient hiveClient)
        throws IOException, TException, InterruptedException {
  
      LOG.info(HiveConf.ConfVars.METASTORE_USE_THRIFT_SASL.varname + ": " + hiveConf.get(
          HiveConf.ConfVars.METASTORE_USE_THRIFT_SASL.varname));
  
      LOG.info(HiveConf.ConfVars.METASTORE_KERBEROS_PRINCIPAL.varname + ": " + hiveConf.get(
          HiveConf.ConfVars.METASTORE_KERBEROS_PRINCIPAL.varname));
  
      final Token<DelegationTokenIdentifier> hcatToken = new Token<>();
  
      hcatToken.decodeFromUrlString(
          hiveClient.getDelegationToken(userToProxy, UserGroupInformation.getLoginUser().getShortUserName()));
  
      // overwrite the value of the service property of the token if the signature
      // override is specified.
      // If the service field is set, do not overwrite that
      if (hcatToken.getService().getLength() <= 0 && tokenSignatureOverwrite != null
          && tokenSignatureOverwrite.trim().length() > 0) {
        hcatToken.setService(new Text(tokenSignatureOverwrite.trim().toLowerCase()));
  
        LOG.info(HIVE_TOKEN_SIGNATURE_KEY + ":" + tokenSignatureOverwrite);
      }
  
      LOG.info("Created hive metastore token for user:" + userToProxy + " with kind[" + hcatToken.getKind() + "]"
          + " and service[" + hcatToken.getService() + "]");
      return hcatToken;
    }
docs: function to fetch hcat token as per the specified hive configuration and then store the token
  in to the credential store specified .
  
  @param userToProxy String value indicating the name of the user the token will be fetched for.
  @param hiveConf the configuration based off which the hive client will be initialized.