docs: @SuppressWarnings("unchecked")
  	public String generateToken(TokenOptions tokenOptions) throws OpenViduJavaClientException, OpenViduHttpException {
  
  		if (!this.hasSessionId()) {
  			this.getSessionId();
  		}
  
  		HttpPost request = new HttpPost(OpenVidu.urlOpenViduServer + OpenVidu.API_TOKENS);
  
  		JSONObject json = new JSONObject();
  		json.put("session", this.sessionId);
  		json.put("role", tokenOptions.getRole().name());
  		json.put("data", tokenOptions.getData());
  		if (tokenOptions.getKurentoOptions() != null) {
  			JSONObject kurentoOptions = new JSONObject();
  			if (tokenOptions.getKurentoOptions().getVideoMaxRecvBandwidth() != null) {
  				kurentoOptions.put("videoMaxRecvBandwidth",
  						tokenOptions.getKurentoOptions().getVideoMaxRecvBandwidth());
  			}
  			if (tokenOptions.getKurentoOptions().getVideoMinRecvBandwidth() != null) {
  				kurentoOptions.put("videoMinRecvBandwidth",
  						tokenOptions.getKurentoOptions().getVideoMinRecvBandwidth());
  			}
  			if (tokenOptions.getKurentoOptions().getVideoMaxSendBandwidth() != null) {
  				kurentoOptions.put("videoMaxSendBandwidth",
  						tokenOptions.getKurentoOptions().getVideoMaxSendBandwidth());
  			}
  			if (tokenOptions.getKurentoOptions().getVideoMinSendBandwidth() != null) {
  				kurentoOptions.put("videoMinSendBandwidth",
  						tokenOptions.getKurentoOptions().getVideoMinSendBandwidth());
  			}
  			if (tokenOptions.getKurentoOptions().getAllowedFilters().length > 0) {
  				JSONArray allowedFilters = new JSONArray();
  				for (String filter : tokenOptions.getKurentoOptions().getAllowedFilters()) {
  					allowedFilters.add(filter);
  				}
  				kurentoOptions.put("allowedFilters", allowedFilters);
  			}
  			json.put("kurentoOptions", kurentoOptions);
  		}
  		StringEntity params;
  		try {
  			params = new StringEntity(json.toString());
  		} catch (UnsupportedEncodingException e1) {
  			throw new OpenViduJavaClientException(e1.getMessage(), e1.getCause());
  		}
  
  		request.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
  		request.setEntity(params);
  
  		HttpResponse response;
  		try {
  			response = OpenVidu.httpClient.execute(request);
  		} catch (IOException e2) {
  			throw new OpenViduJavaClientException(e2.getMessage(), e2.getCause());
  		}
  
  		try {
  			int statusCode = response.getStatusLine().getStatusCode();
  			if ((statusCode == org.apache.http.HttpStatus.SC_OK)) {
  				String token = (String) httpResponseToJson(response).get("id");
  				log.info("Returning a TOKEN: {}", token);
  				return token;
  			} else {
  				throw new OpenViduHttpException(statusCode);
  			}
  		} finally {
  			EntityUtils.consumeQuietly(response.getEntity());
  		}
  	}