It looks like you're new here. If you want to get involved, click one of these buttons!
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}")
session.get(login_url)
call since morning. any advice on why this is happening?