I want to send buy/sell signal webhook triggers from my tradingview account to firebase cloud function and then execute the order according to that.
But Zerodha requiring me to generate a request_token for every time the webhook gets triggered. How can I request a new request_token programmatically.
You don't need to generate a new request token everytime you make a request. You can generate request token once every day,use that to generate access token,and save the access token in your database. This access token is valid for one whole day. Use set access token method to make requests. https://kite.trade/docs/kiteconnectjs/v3/KiteConnect.html#setAccessToken
Exchange mandates the user to login manually atleast once a day. So,automating login is not recommended.
Params is a javascript object with tradingsymbol, exchange etc. as key-value pairs.
So basically everytime I call generateSession the token expires. I guess it's not really possible to do that in firebase cloud functions as everytime we call a function, it resets everything (As per my knowledge).Please lemme know if I'm wrong.
A request token is valid only for a few minutes. After that, it expires. You have to enter request token and api_secret in the generate session function and retrieve the access_token from the response. And use that access token for the whole day. You can learn login flow here: https://kite.trade/docs/connect/v3/user/
@SRIJAN decided to host a standalone nodejs express app in the end. But problem is I'm not really active at indian trading hours. So if I refresh the token at around 12am to 3am midnight. Will it work for the next 24 hours?
I mean if for some reasons it expires in trading hours, it can cause some problems or possibly losses.
https://kite.trade/docs/kiteconnectjs/v3/KiteConnect.html#setAccessToken
Exchange mandates the user to login manually atleast once a day. So,automating login is not recommended.
Params is a javascript object with tradingsymbol, exchange etc. as key-value pairs.
Here's the cloud function code I'm testing...
https://kite.trade/docs/connect/v3/user/
I mean if for some reasons it expires in trading hours, it can cause some problems or possibly losses.
https://kite.trade/forum/discussion/comment/20193/#Comment_20193