﻿# The example shows how to obtain station name and password from a ticket

# SABClient methods used:
#
# login(self, username, password, domain='system', access_code=None)
# logout(self)
# get_ticket_password(self, ticket_id, station_name, user_name, platform):

import sys
import json
import sabclient


################################## main ######################################################

# first we need to create SecureAnyBox (SAB) client for given SAB server address (including base path);
# the callback applies when the second factor is required to sign in
sab = sabclient.SABClient('http://127.0.0.1:8843/secureanybox/')

# get_ticket_password returns the result a dictionary

data = sab.get_ticket_password('850c815359d49e6ba0b74b02dc4e82be9cd1dac4bfca5a8574ca69b7f9e7e838', 'PC1')

if data['password'] != None:
    print('username = ', data['userName'])
    print('password = ', data['password'])

