Kotak-Neo / kotak-neo-api

113 stars 105 forks source link

Unable to login #70

Open prabudhkhare opened 1 year ago

prabudhkhare commented 1 year ago

client = NeoAPI(consumer_key="", consumer_secret="", environment='uat', on_message=on_message, on_error=on_error, on_close=None, on_open=None) client.login(mobilenumber="+919999999999", password="XXXX")

I am getting below error on above two lines. (i obviously used my own client secrets/key , mobile number and password)

ERROR msg (0) Reason: ConnectionError ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

Traceback (most recent call last): File "C:\Users\khare\OneDrive\Desktop\test.py", line 19, in client.login(mobilenumber="+918171666415", password="1995)Cool") File "C:\Users\khare\AppData\Local\Programs\Python\Python311\Lib\site-packages\neo_api_client\neo_api.py", line 117, in login view_token = neo_api_client.LoginAPI(self.api_client).generate_view_token(password=password, mobilenumber=mobilenumber, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\khare\AppData\Local\Programs\Python\Python311\Lib\site-packages\neo_api_client\api\login_api.py", line 58, in generate_view_token header_params = {'Authorization': "Bearer " + self.api_client.configuration.bearer_token}


TypeError: can only concatenate str (not "NoneType") to str
syedasif11 commented 1 year ago

I believe you need to change environment='uat' to environment='prod'

prabudhkhare commented 1 year ago

Hi ,

I was trying with that only, the error logs are from prod env only

image

image

darshil-lakhani commented 1 year ago

@prabudhkhare Hi , so the issue you have created seems tricky. the problem here is, when the client is initialized , usually a new bearer_token is created , but in your case that is None please try this and get back with the response you get in the print statement

client = NeoAPI(consumer_key="", consumer_secret="",
environment='prod', on_message=on_message, on_error=on_error, on_close=None, on_open=None)
print(client.api_client.configuration.__dict__)

just run the above code and share the response (mask your creds partially) it should be something like this

{'consumer_key': 'xxxxxxxx', 'consumer_secret': 'xxxxxxxxx', 'host': 'prod', 'base64_token': 'xxxxx', 'bearer_token': 'xxxxxxx', 'view_token': None, 'sid': None, 'userId': None, 'edit_token': None, 'edit_sid': None, 'edit_rid': None, 'serverId': None, 'login_params': None, 'neo_fin_key': None}

The important thing to note here is, "bearer_token" should be None to get the error which you got, if it is None then get back here, we'll see what we can do next. If it is not None, then you shouldn't get the error you got, so in both the cases there is some problem .

prabudhkhare commented 1 year ago

image

image

Hi @darshil-lakhani , I have tried your suggestion and attached screenshots for the same, 'bearer_token' is actually None

geek-coder commented 1 year ago

@prabudhkhare If you have browser access to same m/c from where you are running above code, then try accessing kotak trading terminal directly, and try apis from same place where you generated consumer key. May be you will see error description.

Kotak is using radware cloud for ddos protection. May be for some reason your ip got blocked. or you have some firewall/intermediary which is blocking access to server.

darshil-lakhani commented 1 year ago

@prabudhkhare try to run this on google collab once, If its IP issue on your system then, google collab should work for you.

AlbertBGeorge commented 1 year ago

I had the same issue, somehow it worked after I restarted my modem. But it's a serious issue, could you please work with the Kotak's ddos team to fix this?

Kotak-Neo commented 11 months ago

@prabudhkhare Kindly try to run it in the Sample Google Colab Notebook and check if you are still facing the issue.

prabudhkhare commented 11 months ago

@Kotak-Neo it is working from google colab, but getting the mentioned error while running from local, I have also added inbound/outbound rules for python.exe, cmd, powershell , also turned off antivirus, windows defender, but the issue couldn't be resolved on my local

sumit12dec commented 10 months ago

@Kotak-Neo Getting the same issue. Generating the client object on AWS lambda and storing in db but when using the same object after 30 mins it says

{'code': '900901', 'message': 'Invalid Credentials', 'description': 'Invalid JWT token. Make sure you have provided the correct security credentials'}