def login(self, password): user_credentials = UserCredentials(userid=self.userid, password=password) login_response_res = ks_api_client.SessionApi(self.api_client).login_with_user_id(self.consumer_key, \ self.ip, self.app_id, UserCredentials = user_credentials) login_response = '' if (login_response_res.get("Success")): login_response = login_response_res.get("Success") elif (login_response_res.get("success")): login_response = login_response_res.get("success") self.one_time_token = login_response['oneTimeToken'] return login_response_res
def __init__(self, access_token, userid, consumer_key, ip, app_id, host = "https://sbx.kotaksecurities.com/apim", proxy_url = '',\ proxy_user = '', proxy_pass = ''): self.host = host self.userid = userid self.consumer_key = consumer_key self.ip = ip self.app_id = app_id self.access_token = access_token configuration = self.get_config(proxy_url, proxy_user, proxy_pass) self.api_client = ks_api_client.ApiClient(configuration) session_init_res = ks_api_client.SessionApi(self.api_client).session_init(self.userid, \ self.consumer_key, self.ip, self.app_id) session_init = '' if (session_init_res.get("Success")): session_init = session_init_res.get("Success") elif (session_init_res.get("success")): session_init = session_init_res.get("success") if self.host != session_init['redirect']['host']: self.host = session_init['redirect']['host'] configuration = self.get_config(proxy_url, proxy_user, proxy_pass) self.api_client = ks_api_client.ApiClient(configuration) session_init = ks_api_client.SessionApi(self.api_client).session_init(self.userid, \ self.consumer_key, self.ip, self.app_id)
def generate_session2_fa(self, access_code): user_details = UserDetails(userid=self.userid, accessCode=access_code) if self.one_time_token: generate_session_res = ks_api_client.SessionApi(self.api_client).generate_session2_fa(self.one_time_token, \ self.consumer_key, self.ip, self.app_id, UserDetails = user_details) generate_session = '' if (generate_session_res.get("Success")): generate_session = generate_session_res.get("Success") elif (generate_session_res.get("success")): generate_session = generate_session_res.get("success") self.session_token = generate_session['sessionToken'] return generate_session else: raise ApiValueError( "Please invoke 'session_login_api' function first")
def logout(self): logout = ks_api_client.SessionApi(self.api_client).session_logout(self.session_token,self.consumer_key,\ self.ip, self.app_id, self.userid) return logout