urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 61] Connection refused
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=5010): Max retries exceeded with url: /login?status=success&request_token=N0GjGXhjpVdoFLfy4831Hty3VXQYwPW5&action=login&type=login (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 61] Connection refused'))
You seem to be using APIs that are not part of the KiteConnect. Bear in mind that automating authentication is against exchange regulations and using unofficial APIs will lead to unforeseen disruptions.
I am trying to automate the login process where userid and password can be entered by code only. I am using below api is this not correct ? 'https://kite.trade/connect/login?v=3&api_key='
Please follow the method to authenticate as described here: https://kite.trade/docs/connect/v3/user/#login-flow
'https://kite.trade/connect/login?v=3&api_key='
def login():
http_session = requests.Session()
url = http_session.get(url='https://kite.trade/connect/login?v=3&api_key='+api_key).url
response = http_session.post(url='https://kite.zerodha.com/api/login', data={'user_id':user_id, 'password':user_password})
status = response.status_code
resp_dict = json.loads(response.content)
print(resp_dict)
totp = pyotp.TOTP(totp_key)
twofa_value = totp.now()
response1 = http_session.post(url='https://kite.zerodha.com/api/twofa', data={'user_id':user_id, 'request_id':resp_dict["data"]["request_id"], 'twofa_value': twofa_value, 'twofa_type': resp_dict["data"]["twofa_type"]})
url = url + "&skip_session=true"
response = http_session.get(url=url, allow_redirects = True).url
request_token = parse_qs(urlparse(response).query)['request_token'][0]
print(request_token)
kite = KiteConnect(api_key=api_key)
data = kite.generate_session(request_token, api_secret=api_secret)
kite.set_access_token(data["access_token"])