Any change pushed to login flow today?

k448
I have a login script that was working fine till today market open. Here's a simplified version of the same
LOGIN_URL = "https://kite.zerodha.com/api/login"
TWOFA_URL = "https://kite.zerodha.com/api/twofa"
kite = KiteConnect(api_key=creds['API_KEY'])
login_url = kite.login_url()
print(f"login url is {login_url}")
try:
session = requests.Session()
print(f"user_id {creds['user_id']}")
# Get request id in response
response = session.post(LOGIN_URL, data={'user_id': creds['user_id'], 'password': creds['password']})
if(response.status_code != 200):
print(f"Login step 1 failed: {response.status_code} - {response.text}")
exit

request_id = json.loads(response.text)['data']['request_id']
# Two factor authentication
twofa_pin = pyotp.TOTP(creds['totp_key']).now()
response = session.post(TWOFA_URL, data={'user_id': creds['user_id'], 'request_id': request_id, 'twofa_value': twofa_pin, 'twofa_type': 'totp'})
if(response.status_code != 200):
print(f"Login step 2 failed: {response.status_code} - {response.text}")
exit
response = session.get(login_url)
if(response.status_code != 200):
print(f"Login step 3 failed: {response.status_code} - {response.text}")
exit
except Exception as e:
e_msg = str(e)
print(f"login session hit exception - {e_msg}")

I am getting a 404 at the session.get(login_url) call since morning. any advice on why this is happening?
Tagged:
  • k448
    @sujith Any help here please? My understanding is that we perform login flow steps 1 and 2 and then call session.get(login_url) which will internally invoke the registered callback url. This is the step that is failing for me now. I'm using a proper callback url and not the default localhost one.
  • sujith
    It is mandatory by the exchange that a user has to login manually at least once a day. We don't recommend automating login.
  • k448
    Can you define the methodology of said login? Is it mandated that the user should perform the login via a web browser on kite portal and manually key in the credentials and 2fa? Only you guys keep saying this as there are so many other brokers who offer a long lived token for API users. Please help to share which specific SEBI rule you're referring to that mandates the methodology of a login process
Sign In or Register to comment.