I generate the Kite login URL using kite.login_url(). I open the URL and successfully log in to my Zerodha account. Zerodha successfully redirects to my local Flask server at http://127.0.0.1. My Flask application successfully receives the request_token. I then call: data = kite.generate_session( request_token, api_secret=API_SECRET ) The request reaches Kite Connect, but I consistently receive: Invalid `checksum`
What I have already checked:
The Kite Connect app is active. The API Key and API Secret are from the same Kite Connect application. The API Key is being read correctly by Python. The API Secret is being read correctly by Python. API Key length is 16 characters. API Secret length is 32 characters. I regenerated the API Secret and updated it in the Python program. I generated a fresh request token for each login attempt. I am not reusing an old request token. The Python SDK's generate_session() function is being used directly; I am not manually modifying the checksum. I checked the installed SDK source code, and it calculates the checksum as: SHA256(API_KEY + REQUEST_TOKEN + API_SECRET)
The relevant SDK code is:
h = hashlib.sha256( self.api_key.encode("utf-8") + request_token.encode("utf-8") + api_secret.encode("utf-8") )
checksum = h.hexdigest()
The Flask server confirms that the redirect is successful and receives the request token:
GET /?action=login&type=login&status=success&request_token=... HTTP/1.1 200
However, the subsequent generate_session() call always returns:
TokenException: Invalid `checksum`
Could you please help me identify why the checksum is being rejected despite:
an active Kite Connect app, correct API Key/API Secret being used, fresh request tokens, successful Zerodha login and redirect, and the official Kite Connect Python SDK 5.2.1 generating the checksum?
I have intentionally not included my API Key, API Secret, request token, or access token for security reasons.