public static void initCredentialsForCluster(Job job, Configuration conf, URI uri)
    throws IOException {
    UserProvider userProvider = UserProvider.instantiate(conf);
    if (userProvider.isHBaseSecurityEnabled()) {
      try {
        addTokenForJob(() -> ConnectionFactory.createConnection(uri, conf),
          userProvider.getCurrent(), job);
      } catch (InterruptedException e) {
        LOG.info("Interrupted obtaining user authentication token");
        Thread.interrupted();
      }
    }
  }
Obtain an authentication token, for the specified cluster, on behalf of the current user and
add it to the credentials for the given map reduce job.
@param job  The job that requires the permission.
@param conf The configuration to use in connecting to the peer cluster
@param uri  The connection uri for the given peer cluster
@throws IOException When the authentication token cannot be obtained.
hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.java