It looks like you're new here. If you want to get involved, click one of these buttons!
from kiteconnect import KiteConnect
API_KEY = "123456789"
kite = KiteConnect(api_key=API_KEY)
print(kite.login_url())
I then take the key from the browser link and paste it in fetch-token.py
from kiteconnect import KiteConnect
API_KEY = "123456789"
API_SECRET = "123456789"
REQUEST_TOKEN = "Xv4oavF0H4DGh" # From the browser URL
kite = KiteConnect(api_key=API_KEY)
data = kite.generate_session(REQUEST_TOKEN, api_secret=API_SECRET)
# Extract and save access token
access_token = data["access_token"]
print("✅ New Access Token:", access_token)
# ???? Overwrite existing token file
with open("access_token.txt", "w") as f:
f.write(access_token)
upon running fetch-token.py, i store the newly generated access token in access_token.txt. I used to do this in the morning and it would run the entire day. however since last 2 days i am getting an error, Invalid `api_key` or `access_token`
when i try to place a trade. I noticed that the access token that i generate every time is the same (the code doesn't change).
If the issue persists, please enable debug mode and share the complete stack trace here.