Api Rest Client in Java

0

I am building a REST client according to the example link and I have two errors that I could not correct

My Code:

 public void ClienteApiRest()
    {
      javax.ws.rs.client.Client client = ClientBuilder.newClient();
      WebTarget target = client.target(IDP_URI + "/token");
      Form form = new Form();
                form.param("grant_type", "password")
               .param("username",usuario)
               .param("password", password)
               .param("client_id", client_id);
                Response response = target.request().post(Entity.form(form));
      JsonObject responseJson = response.readEntity(JsonObject.class);
      String acessToken = responseJson.getString("access_token");
      String refreshToken =responseJson.getString("refresh_token");
      jTextField1.setText(acessToken + " " + refreshToken);
    }

The errors are in these bold lines:

Response response = target.request (). post (Entity. form (form));

JsonObject responseJson = response. readEntity (JsonObject.class);

What can I do to correct them?

    
asked by Efrain Mejias C 28.11.2017 в 22:28
source

0 answers