WinKAS Credential system

In WinKAS Credential system there is 2 main logon functions that you need to use to get access to all the different methods in the system. Read more about these methods here – Link to API Description

The credential system is “Token” based and therefore you will receive a token when you have a successfull login with the methods: “User authentication” – “Token Authentication”

User authentication

If you don´t have a token you will need to do a complete authentication where you provide the system with all the needed information.. If successful you will get a “token”.


Requesttype: Post

Body: {“UserName”:”NAME”, “UserPassword”:”PASSWORD”, “UserContractCode”:”CODE”}

Parameters description:

Name: Username

Password: Password

Code: The code/contractcode is normally the licensnumber.


Token authentication

if you already in possession of a validated “token” and just need to login, then make this simple “token” authentication.


Requesttype: Post

Body: {“UserToken”:”TOKEN”}

Parameters description:

Token: An existing token.

As mentioned above the result of a successful authentication will return a validated “token” for you. You will need this token for all WinKAS API requests.

Code examples – user authentication.


public string GetToken()
       var httpWebRequest = (HttpWebRequest)WebRequest.Create("");
        httpWebRequest.ContentType = "text/json";
        httpWebRequest.Method = "POST";

        using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            string json = new JavaScriptSerializer().Serialize(new
                UserName = "xxxxx",
                UserPassword = "xxxxx",
                UserContractCode = "xxxxx"              


            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                var _jsonAuth = streamReader.ReadToEnd();

                dynamic _jsonContent = JsonConvert.DeserializeObject(_jsonAuth);
                string _token = _jsonContent.WinKasData.CurrentToken;

                return _token;

    $(document).ready(function () {
        var winkasServer = (function () {
            var getAccounts = function (request) {
                return $.ajax(
                '', {
                    type: "POST",
                    data: request
            var authenticate = function (request) {
                return $.ajax(
                '', {
                    type: "POST",          
                    data: request
            return {
                getAccounts: getAccounts,
                authenticate: authenticate
        var el = {
            btnAction: $('#action'),
            result: $('#result')
        el.btnAction.on('click', function () {
            var request = {
                "UserName": "xxxxx",
                "UserPassword": "xxxxx",
                "UserContractCode": "xxxxx"
            winkasServer.authenticate(request).done(function (data) {
                var token = data.WinKasData.CurrentToken;
                request = {
                    "Token": token
                winkasServer.getAccounts(request).done(function (accounts) {
                    var acc = accounts.Accounts;
                    var html = "";
                    for (var i = 0; i < acc.length; i++) {
                        html += acc[i].Number + ", ";

//create array of data to be posted
$post_data['UserName'] = 'xxxxx'; //You should add your test user
$post_data['UserPassword'] = 'xxxxx'; //You should add your test password
$post_data['UserContractCode'] = 'xxxxx'; //You should add your test account/contract

//traverse array and prepare data for posting (key1=value1)
foreach ( $post_data as $key => $value) {
	$post_items[] = $key . '=' . $value;

//create the final string to be posted using implode()
$post_string = implode ('&', $post_items);

//create cURL connection
$curl_connection = curl_init('');

//set options
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);

//set data to be posted
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);

//perform our request
$result = curl_exec($curl_connection);

//dump result
echo '
echo '
------------------------ '; //show information regarding the request echo '
echo '
'; //close the connection curl_close($curl_connection); 
ASP (classic)

<% '/// Include json converter - %>
<!--#include file="aspJSON1.17.asp" -->
Const apiUrl = ""
Dim apiMethod
Dim requestBody
Dim apiResponse
Dim responseBody
Dim responseStatus
Dim responseMessage
Dim httpService
Dim token

'/// Get access token

apiMethod = "Authentication/Authenticate"

Set requestBody = New aspJSON

	.Add "UserName", "xxxxx"
	.Add "UserPassword", "xxxxx"
	.Add "UserContractCode", "xxxxx"
End With

Set httpService = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0") "POST", apiUrl & apiMethod
httpService.setRequestHeader "Content-Type", "application/json; charset=utf-8"
httpService.send requestBody.JSONoutput
apiResponse = httpService.responseText

Set responseBody = New aspJSON
responseBody.loadJSON apiResponse

responseStatus ="WinKasStatus")
responseMessage ="WinKasMessage")

If responseStatus <> 0 Then 
	Response.Write "<p>Authentication failed!</p>"
	Response.Write "<p>" & responseMessage & "</p>"
End If

token ="WinKasData").item("CurrentToken")