Request Token invalid

rajagopalsri
I was able to generate a request using python and saved it in a text file. (@ 2:40 pm 13 Nov 2020)

When I try to create an access token (immediately) using the above request token, I get an error

Token is invalid or has expired.

Please help resolve

''------------------------------ code -----------------------'
time.sleep(3)
request_token = open("request_token.txt",'r').read()
key_secret = open("api_key.txt",'r').read().split()
try:
print(request_token,key_secret[0])
kite = KiteConnect(api_key=key_secret[0])
data = kite.generate_session(request_token, api_secret=key_secret[1])
print(data["access_token"])
with open('access_token.txt', 'w') as file:
file.write(data["access_token"])
  • rakeshr
    @rajagopalsri
    Above flow seems fine. Can you re-check, if you are capturing correct request_token, api_key and api_secret?
    request_token = open("request_token.txt",'r').read()
    key_secret = open("api_key.txt",'r').read().split()
  • sujith
    You can refer to this thread.
  • rajagopalsri
    thanks for the quick response rakeshr and sujith

    i resolved it, made an error in passing the wrong key - thanks
This discussion has been closed.