☰
Login
Signup
Home
›
Python client
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Register
Categories
Recent Discussions
Activity
Categories
13.8K
All Categories
0
Incidents
152
Node JS client
39
Go client
791
.Net API client
378
Kite Publisher
537
.Net / VBA / Excel (3rd party)
457
Algorithms and Strategies
992
Java client
1.1K
API clients
402
PHP client
4K
Python client
346
Mobile and Desktop apps
1.4K
Market data (WebSockets)
3.3K
General
In this Discussion
January 29
sujith
Invalid Token
Naga2405
January 26
in
Python client
Hi,
I was trying to get the historical data for a single instrument token using kiteconnect. The code for the same is as shown:
from kiteconnect import KiteConnect
from kiteconnect import KiteTicker
import os
import datetime as dt
import pandas as pd
api_k = ""
api_s = ""
def get_login(api_k, api_s):
global kws, kite
kite = KiteConnect(api_key=api_k)
print("[*] Generate access Token : ", kite.login_url())
request_tkn = input("[*] Enter Your Request Token Here : ")
data = kite.generate_session(request_tkn, api_secret=api_s)
kite.set_access_token(data["access_token"])
kws = KiteTicker(api_k, data["access_token"])
# Example usage:
get_login(api_k, api_s)
vfrom = "2023-08-05"
vto = "2023-12-10"
ohlc = kite.historical_data(12053506, vfrom, vto, '30minute')
print(ohlc)
When I run this code I get the following error: 'invalid token'
I must mention that the API token is freshly generated today and the other kiteconnect calls such as those for fetching ohlc data work perfectly.
May I know why is my call not working?
Tagged:
Python Client
sujith
January 29
You shouldn't call generate session every time you run the script. You can know more about it
here
.
Sign In
or
Register
to comment.