Skip to content

User Authentication

Get a Ticket

In order to perform any operation with TACTIC, you must have a valid ticket. Temporary tickets can be issued with the user's login and password. It is very common for an applicaton to have a custom login page. Using the TACTIC API, you can use the get_ticket method in order to obtain a new valid ticket:

Using Javascripts API:

let server_url = "https://portal.southpawtech.com"
let site = "trial"
let project = "api_test"
let user = 'trial_api'
let password = 'tactic123'

let server = TACTIC.get();
server.set_server(server_url)
server.set_site(site)
server.set_project(project)

let ticket = server.get_ticket(user, password);

Note

Try a simple login example in JSFiddle here.

Using REST API:

let base_endpoint = "https://portal.southpawtech.com/" + site + "/" + project + "/REST";

let ticket = ""

let kwargs = {
    login: 'trial_api',
    password: 'tactic123'
}

call_tactic('get_ticket', kwargs).then(function(value) {
    ticket = value;
}).catch(function(e) {
    console.error(e.message);
})

const call_tactic = async (method, kwargs) => {

    let data = kwargs

    let url = get_endpoint() + "/" + method

    let headers = {
        "Authorization": "Bearer " + ticket,
        Accept: 'application/json',
    }
    let r = await fetch( url, {
        method: 'POST',
        mode: 'cors',
        headers: headers,
        body: JSON.stringify(data),
    } )

    if (r.status == 200) {
        let ret = await r.json();
        return ret;
    }
    else {
        throw("ERROR: " + r.statusText);
    }
}

const get_endpoint = () => {
    return base_endpoint;
}

Note

Try a simple login example in JSFiddle here.

Once you have a ticket, it is useful to store it somewhere other than memory so that it can be reused (local storage or a cookie, for example). Tickets have an expiry date at which point the user will have to log in again. In our React application, we use Storage plugin to store all the credentials as key-value pairs.

The ticket will have all of the permissions that a user has.

Restricted Tickets

Todo