Basic login integration to receive TOKEN.

Hi.

I try to create solution to log in, get TOKEN and then retrieve information from other API(like cameras state etc).

Then problem begins on login request, as in documentation i dont see valid example. Take a look in here http://doc.developer.milestonesys.com/html/reference/protocols/imageserver_authenticate.html

  1. Where to put login credentials such as userName and Password?

  2. Authorization: {autogenerated by HTTP library or class applied} ← i want to generate it by myself, can I ?

  3. What service should I use? From example above its should be ServerCommandService or ServerApi, but from here

http://doc.developer.milestonesys.com/html/index.html?base=samples/logindotnetsoap.html&tree=tree_3.html

we get ManagementServer/ServerCommandService.svc

So can someone give example in any language how to properly construct headers, XML to send valid log in request.

Thank you .

LoginDotNetSoap is the correct sample, ServerCommandService.svc is the right place to login. You should then use token while communicating on the Image Server. We have made an improved sample for 2019R1 and hopefully you will find this improvement gives you the answers. The sample is beta but we believe it is the final version, your feedback would be appreciated.

http://download.milestonesys.com/MIPSDK/Samples/protocol_MIPSDK2019R1_BetaSamples.zip

Hi @Bo Ellegård Andersen (Milestone Systems)​ . Thank you for answer. Example is great, but my problem is still there.

Basically im looking for a way how to obtain token using different language(not c#).

Especially Node JS.

I want to know is it possible to do something like this and get token from server.

const https = require('https');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
let post_data = `<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><Login xmlns="http://videoos.net/2/XProtectCSServerCommand"><instanceId>{guid}</instanceId></Login></soap:Body></soap:Envelope>\r\n\r\n`;
// An object of options to indicate where to post to
let post_options = {
    host: 'windev1809eval',
    port: '443',
    path: '/ManagementServer/ServerCommandService.svc',
    method: 'POST',
    headers: {
        'Content-Type': 'text/html; charset=us-ascii',
        'Content-Length': Buffer.byteLength(post_data),
        'Authorization': 'Basic YWRtaW4gYWRtaW4=',
        'SOAPAction': 'http://videoos.net/2/XProtectCSServerCommand/Login'
    }
};
// Set up the request
var post_req = https.request(post_options, function(res) {
    res.setEncoding('utf8');
    res.on('data', function (chunk) {
        console.log('Response: ' + chunk);
    });
});
// post the data
post_req.write(post_data);
post_req.end();

Or i will need to use different approach to get that.

Thank you.

I might have been a bit fast when saying ServerCommandService.svc is the right place to login. These protocols are different depending on whether you have an XProtect e-code or c-code VMS. The sample you have in this thread will show you this. See also -

http://doc.developer.milestonesys.com/html/index.html?base=gettingstarted/intro_soap_protocols.html&tree=tree_3.html

What XProtect are you aiming to use? What are you currently working with?

One way to get to the bottom of what goes on is to trace the network communication with Wireshark or similar, then compare what does your program do differently than the sample from Milestone.