paramatrixtech / ksapi

Kotak Securities Trading APIs Integration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

{ "fault": { "code": 999003, "description": "Please refer https://www.kotaksecurities.com/itrade/user/marketing.exe?action=trade_api&req=92", "message": "You are not authorized to access this platform. Please refer https://www.kotaksecurities.com/itrade/user/marketing.exe?action=trade_api&req=92" } }

kalilinux-png opened this issue · comments

Any Idea

mee to have the Invalid One-time token issue Send a Mail they told me to make changes in the endpoint. so sick

mee to have the Invalid One-time token issue Send a Mail they told me to make changes in the endpoint. so sick

With me the same thing is working for my account but when i try this with another account it raised error

you can search in google "HTTPS" endpoint.
they told me with a mail like this:
Add below endpoints in your code

session token generate
Use the below endpoints in the order mentioned below-

  1. POST​/session​/login​/userid Login using Userid
  2. POST​/session​/2FA​/accesscode Generate final Session Token

after this message they mailed me saying that the problem is resolved.
they are not willing to help.
KotakSecurities would be India's best brokers if they hired the Proper staff.

Use below code, it will be easier.

api = ks_api.KSTradeApi(access_token = access_token, userid = user_id, consumer_key = consumer_key, ip = ip, consumer_secret = consumer_secret, host = "https://tradeapi.kotaksecurities.com/apim")

def login():
global api

login_data = api.login(password)
one_time_token = login_data['Success']['oneTimeToken']

headers = {'accept':'application/json',
        'oneTimeToken':one_time_token,
        'consumerKey':consumer_key,
        'ip':ip,
        'appId':consumer_secret,
        'Authorization':'Bearer '+access_token,
        'Content-Type':'application/json'}

data = {'userid': user_id}

response = json.loads(requests.post(url = url, headers = headers, data = json.dumps(data)).content)

return response

response = login()
api.session_token = response['success']['sessionToken']