Kotak-Neo / kotak-neo-api

117 stars 111 forks source link

Not able to connect to Kotak API #230

Open rohit-r-soni opened 2 months ago

rohit-r-soni commented 2 months ago

getting error since today

2024-09-09 22:25:12   File "/usr/local/lib/python3.10/site-packages/neo_api_client/neo_api.py", line 114, in login
2024-09-09 22:25:12     view_token = neo_api_client.LoginAPI(self.api_client).generate_view_token(password=password, mobilenumber=mobilenumber,
2024-09-09 22:25:12   File "/usr/local/lib/python3.10/site-packages/neo_api_client/api/login_api.py", line 77, in generate_view_token
2024-09-09 22:25:12     view_token_json_resp = json.loads(generate_view_token.text)
2024-09-09 22:25:12   File "/usr/local/lib/python3.10/json/__init__.py", line 346, in loads
2024-09-09 22:25:12     return _default_decoder.decode(s)
2024-09-09 22:25:12   File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode
2024-09-09 22:25:12     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
2024-09-09 22:25:12   File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode
2024-09-09 22:25:12     raise JSONDecodeError("Expecting value", s, err.value) from None
2024-09-09 22:25:12 json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

code for reference (was working before)

def initiate_session(self):
        mobile_number = os.getenv('KOTAK_SECURITIES_MOBILE_NUMBER')
        password = os.getenv('KOTAK_SECURITIES_PASSWORD')
        pin = os.getenv('KOTAK_SECURITIES_PIN')
        access_token = os.getenv('KOTAK_SECURITIES_ACCESS_TOKEN')

        client = NeoAPI(access_token=access_token, environment='prod')
        client.login(mobilenumber=mobile_number, password=password)
        client.session_2fa(OTP=pin)

        # Set up callbacks for WebSocket events
        client.on_message = self.on_message
        client.on_error = self.on_error
        client.on_close = self.on_close
        client.on_open = self.on_open

        return client
anup-patel commented 2 months ago

Seems like KOTAK API work only between a time range. I also noticed that it was not working around 8:30 AM but working at 9:15. It not working at 8PM ... Its strange