Kotak-Neo / kotak-neo-api

100 stars 86 forks source link

gen_otp = neo_api_client.LoginAPI(self.api_client).generate_otp() #54

Open comeback2000 opened 10 months ago

comeback2000 commented 10 months ago

Getting error when i run this code

client.login(mobilenumber="+91myphobenumber", password="mypassword") client.session_2fa(OTP="1040")

ApiValueError                             Traceback (most recent call last)
Cell In[4], line 1
----> 1 client.login(mobilenumber="+91myphobenumber", password="mypassword")
      2 client.session_2fa(OTP="1040")

File C:\NSE\Python Script\NEO\kotak-neo-api-main\neo_api_client\neo_api.py:120, in NeoAPI.login(self, password, mobilenumber, userid, pan, mpin)
    117 view_token = neo_api_client.LoginAPI(self.api_client).generate_view_token(password=password, mobilenumber=mobilenumber,
    118                                                                           userid=userid, pan=pan, mpin=mpin)
    119 if "error" not in view_token:
--> 120     gen_otp = neo_api_client.LoginAPI(self.api_client).generate_otp()
    121     print(gen_otp)
    122 else:

File C:\NSE\Python Script\NEO\kotak-neo-api-main\neo_api_client\api\login_api.py:86, in LoginAPI.generate_otp(self)
     84 def generate_otp(self):
     85     header_params = {'Authorization': "Bearer " + self.api_client.configuration.bearer_token}
---> 86     userId = self.api_client.configuration.extract_userid(self.api_client.configuration.view_token)
     87     body_params = {
     88         "userId": userId,
     89         "sendEmail": True,
     90         "isWhitelisted": True
     91     }
     92     URL = self.api_client.configuration.get_url_details("generate_otp")

File C:\NSE\Python Script\NEO\kotak-neo-api-main\neo_api_client\neo_utility.py:47, in NeoUtility.extract_userid(self, view_token)
     45 def extract_userid(self, view_token):
     46     if not view_token:
---> 47         raise ApiValueError(
     48             "View Token hasn't been Generated Kindly Call the Login Function and Try to Generate OTP")
     49     decode_jwt = jwt.decode(view_token, options={"verify_signature": False})
     50     userid = decode_jwt.get("sub")

ApiValueError: View Token hasn't been Generated Kindly Call the Login Function and Try to Generate OTP
Kotak-Neo commented 9 months ago

Kindly share the full code snippet, including the initialization if you are still facing the issue.

Sumit2701 commented 6 months ago

from neo_api_client import NeoAPI

client = NeoAPI(consumer_key=ck,consumer_secret=cs,environment="prod")

    # Login using password
client.login(mobilenumber=mb, password=ps)

``` i am getting same error for this code
ravisubbu97 commented 6 months ago

@Kotak-Neo I am also getting the same issue..

@Sumit2701 or @comeback2000 you got any solution for this problem..?

ravisubbu97 commented 4 months ago

It is not working for environment = 'uat' and is only working for environment='prod'..

@Kotak-Neo - now, at least take up the responsibility to fix it..

chitrakshadusane commented 3 months ago

Getting the same issue at the time of login @Kotak-Neo As using the environment="uat"

crypt0inf0 commented 3 months ago

@chitrakshadusane Use environment='prod'