checksum error while getting the access_token

gurugg0802
code
**************************************************
from kiteconnect import KiteConnect

api_key = "xxxxxxxxxxxxxxxx"

api_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

kite = KiteConnect(api_key=api_key)
request_token = kite.login_url()
print(request_token)
access_token = kite.generate_session(kite.login_url(), api_secret=api_secret)
kite.set_access_token(data[access_token])
print(data["access_token"])
**************************************************

request token

*********************************************************
https://kite.trade/connect/login?api_key=xxxxxxxxxxxxxxxx&v=3
*********************************************************

error
**************************************************
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.kite.trade:4
43
DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "POST /session/token HTT
P/1.1" 403 None
Traceback (most recent call last):
File "get_request_token.py", line 19, in
access_token = kite.generate_session(kite.login_url(), api_secret=api_secret
)
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-pac
kages\kiteconnect\connect.py", line 252, in generate_session
"checksum": checksum
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-pac
kages\kiteconnect\connect.py", line 821, in _post
return self._request(route, "POST", params)
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-pac
kages\kiteconnect\connect.py", line 886, in _request
raise exp(data["message"], code=r.status_code)
kiteconnect.exceptions.TokenException: Token is invalid or has expired.
***************************************************
  • sujith
    It seems like your session is expired, you need to login and get new request token.
  • gurugg0802
    Even after getting a new token same error.
  • gurugg0802
    Today I ran the same with a new generated API secret. Still getting the same error. Should I try to create a new application and try the same?
  • Vinnce
    my api subscription was inactive ... I reactivated it .. and previously working login flow stoped working ..

    getting flowing error
    Array ( [status] => error [message] => Invalid `checksum`. [data] => [error_type] => TokenException )
  • gurugg0802
    Using all correct keys api_key, api_secrete, user_id, and requestToken.

    DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.kite.trade:4
    43
    DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "POST /session/token HTT
    P/1.1" 403 None
    Traceback (most recent call last):
    File "get_request_token.py", line 19, in
    access_token = kite.generate_session(kite.login_url(), api_secret=api_secret
    )
    File "C:\Users\xxxxxxx\AppData\Local\Programs\Python\Python37-32\lib\site-pac
    kages\kiteconnect\connect.py", line 252, in generate_session
    "checksum": checksum
    File "C:\Users\xxxxxxx\AppData\Local\Programs\Python\Python37-32\lib\site-pac
    kages\kiteconnect\connect.py", line 821, in _post
    return self._request(route, "POST", params)
    File "C:\Users\xxxxxxx\AppData\Local\Programs\Python\Python37-32\lib\site-pac
    kages\kiteconnect\connect.py", line 886, in _request
    raise exp(data["message"], code=r.status_code)
    kiteconnect.exceptions.TokenException: Token is invalid or has expired.

    I have read all the relevant discussion but nothing helpful, I can send API keys, secrets separately.
    This app newly created few days back, please help.
  • sujith
    sujith edited August 2020
    Did you go through this thread?
  • gurugg0802
    @sujith , This is a wrong thread as here it is talking about an access token which gets generated and then expires. For me, it is not even getting generated for a new api_secret created on that day. Please help me [email protected].
  • sujith
    You can check the documentation here https://kite.trade/docs/connect/v3/user/
    Double check if you are doing every step properly.
  • Krackmind
    I was facing the same issue (invalid checksum) after my API subscription got expired yesterday. Regenerating the API secret and using it in code solved it for me.
  • gurugg0802
    @sujith, While trying to follow the documentation, I am getting the error while running the /session/token API. It is giving an 400 error (Bad request) that the 'api_key' should be minimum 6 characters in length, so token is not getting generated.
  • sujith
    Are you sure you are making a form post request?
  • gurugg0802
    yes. How can I send the screen shot from Postman request?
  • sujith
    Can you private message the api_key and send me the curl of the request you are making?
  • gurugg0802
    Access token is still not being able to be retreived. Kindly provide the exact algorithm to be able to continue with the application created.
  • sujith
    Everything seems fine with your app. We have tried it multiple times. You can check the login flow here.
Sign In or Register to comment.