Getting 'invalid token' error only fir historical data

svsio
svsio edited December 2019 in General
I have enabled historical data in my account



However, when I try and access this data, I get the following response
{
"status" => "error",
"message" => "invalid token",
"data" => nil,
"error_type" => "InputException"
}
The same token works for account info, margin info and quote. ie

for
/quote/?i=NSE:INFY
I get
{
"NSE:INFY" => {
"instrument_token" => 408065,
"timestamp" => "2019-12-18 12:01:58",
"last_trade_time" => "2019-12-18 12:01:57",
"last_price" => 733.85,
"last_quantity" => 7,
"buy_quantity" => 465682,
"sell_quantity" => 789716,
"volume" => 6079842,
"average_price" => 734.57,
"oi" => 0,
"oi_day_high" => 0,
"oi_day_low" => 0,
"net_change" => 0,
"lower_circuit_limit" => 656.75,
"upper_circuit_limit" => 802.65,
"ohlc" => {
"open" => 731,
"high" => 737.3,
"low" => 730.55,
"close" => 729.7
},
"depth" => {
"buy" => [
[0] {
"price" => 733.75,
"quantity" => 5,
"orders" => 1
},
[1] {
"price" => 733.7,
"quantity" => 95,
"orders" => 4
},
[2] {
"price" => 733.6,
"quantity" => 114,
"orders" => 3
},
[3] {
"price" => 733.55,
"quantity" => 793,
"orders" => 5
},
[4] {
"price" => 733.5,
"quantity" => 3561,
"orders" => 14
}
],
"sell" => [
[0] {
"price" => 733.85,
"quantity" => 43,
"orders" => 2
},
[1] {
"price" => 733.9,
"quantity" => 1120,
"orders" => 9
},
[2] {
"price" => 733.95,
"quantity" => 333,
"orders" => 9
},
[3] {
"price" => 734,
"quantity" => 3164,
"orders" => 44
},
[4] {
"price" => 734.05,
"quantity" => 54,
"orders" => 1
}
]
}
}
}
I have regenerated the API secret and got a new token also but that didn't help.

What can I do to proceed?

  • sujith
    Can you paste your complete code here and paste the complete stacktrace?
    Make sure you run it in debug mode.

    PS: Remove your auth header before posting stacktrace here.
  • svsio
    I figured this out. The "invalid token" refers to the instrumnt token, not the access token. Zerodha, if you update the error message it will save developer some time :-)

    thanks
  • sujith
    You can read about the different types of Kite Connect exceptions here.
Sign In or Register to comment.