When you run the above code, you get the login URL which you use to get the request token. Once you run the above code, you should not run it again (because you'll get a different request token, i.e. the request token will change).
After the above, to generate a kite trading session you run this code:
request_token = 'your_request_token' data = kite.generate_session(request_token, api_secret = api_secret)
One you run the above code, you should not run it again. A request token is like an OTP. You can use it just once. If you use it twice, then you get the error you stated.
After the above, to set access token, you run this code (without running any of the code above again):
kite.set_access_token(data['access_token'])
After you do the whole above process once, just comment out ALL the code above. Don't run it again.
If you're using Jupyter Notebook, don't run those cells again.
For example, this is how you login:
api_key = 'your_api_key'
api_secret = 'your_api_secret'
kite = KiteConnect(api_key = api_key)
print(kite.login_url())
When you run the above code, you get the login URL which you use to get the request token. Once you run the above code, you should not run it again (because you'll get a different request token, i.e. the request token will change).
After the above, to generate a kite trading session you run this code:
request_token = 'your_request_token'
data = kite.generate_session(request_token, api_secret = api_secret)
One you run the above code, you should not run it again. A request token is like an OTP. You can use it just once. If you use it twice, then you get the error you stated.
After the above, to set access token, you run this code (without running any of the code above again):
kite.set_access_token(data['access_token'])
After you do the whole above process once, just comment out ALL the code above. Don't run it again.
If you're using Jupyter Notebook, don't run those cells again.