Trying to setup a DataAbstract Javascript RemoteDataAdapter with custom login

Hello,

I’ve been working from the example data on the web site (https://docs.dataabstract.com/API/JavaScript/Objects/RemoteDataAdapter/).

var rda = new RemObjects.DataAbstract.RemoteDataAdapter("http://" + window.location.host + "/JSON", "MyDataService", "MyLoginService", RemObjects.DataAbstract.JSONDataStreamer);

I have a custom login function that resides in LoginService. How do I use that function with the RemoteDataAdapter (new API) and how do I supply the credentials. I might add I am by no means a Javascript expert I am learning on the fly so please excuse my ignorance. If you have an example that would be wonderful but I’ll take what I can get…:wink:

Additionally the best way to implement OnLoginNeeded would be extremely helpful as well.

As always…Thanks for the help!
Todd

Hello

You need to instantiate the adapter in this way:

var channel = new RemObjects.SDK.HTTPClientChannel("http://localhost:7099/bin");
var message = new RemObjects.SDK.BinMessage();
var service = new RemObjects.SDK.RemoteService(channel, message, "DataService");
var loginService = new your_own_login_service(channel, message); 
var adapter = new RemObjects.DataAbstract.RemoteDataAdapter(service);

adapter.onLoginNeeded = function (aCallback) {
    // Call here your own Login Service
    loginService.login("User=simple;Password=simple;Domain=DASamples;Schema=PCTrade", function (msg) {
        if (aCallback)
            aCallback();
    }, RemObjects.UTIL.ShowError);
}
1 Like

Thanks! That’s what I needed.

1 Like