code: public String generateSecuredApiKey(String privateApiKey, Query query, String userToken) throws NoSuchAlgorithmException, InvalidKeyException {
      if (userToken != null && userToken.length() > 0) {
        query.setUserToken(userToken);
      }
      String queryStr = query.getQueryString();
      String key = hmac(privateApiKey, queryStr);
  
      return Base64.encodeBase64String(String.format("%s%s", key, queryStr).getBytes(Charset.forName("UTF8")));
    }
docs: Generate a secured and public API Key from a query and an
  optional user token identifying the current user
  
  @param privateApiKey your private API Key
  @param query         contains the parameter applied to the query (used as security)
  @param userToken     an optional token identifying the current user