How to login with a REST API server from gluon mobile application. I have tried HttpClient which does able to call .
To access a REST API you can use RestClient.
import com.gluonhq.connect.provider.RestClient;
RestClient restClient = RestClient.create()
.host("http://myhost.com")
.path("restservice/login")
.queryParam("username","myname")
.queryParam("password","myencodedpassword")
.method("GET");
GluonObservableObject<User> sample = DataProvider.retrieveObject(restClient.createObjectDataReader(User.class));
To then handle the result you can use the stateProperty
sample.stateProperty().addListener((obv,ov,nv)->{
if(nv.equals(ConnectState.SUCCEEDED)){
User loggedInUser = sample.get();
}
});
you can use initializedProperty as well.