file_to_dump_file = open(config.KITE_OBJECT_FILE, "wb") dill.dump(kite, file_to_dump_file) # kite being the object you set access token to file_to_dump_file.close()
@r2k1984 No, access_token doesn't expire after every API request. Once you have generated access_token, store it in variable and keep using it for other API calls throughout(until performing logout or fresh login).
Access token once received never expires for 24 hours untill its flushed and cleaned by zerodha daily in morning at around 7:30. You can store that token and reuse.
@r2k1984 i suspect you might have issues due to global/local values, please check your codes once again, may be data path from access generated to access expiry will give you where you went wrong.....
This is the code I'm receiving and storing the data in the access_token in JSON. When i consume the access token the buyorder example.php . It is not working at all.
I have stored the same in the database and using it by the example in php libraries they have provided. But every time I use the token it is getting expired. So every time I have to call the API url and get the toekn for the same.
So once the token is stored in database.. than u have to declare the new KiteConnect instance and call setAccessToken with the token key ..
For example lets say now the token is stored in ur database.. so to start using the api u have to declare a new instance as below .. and once it is done than only u can use lib functions they have given .. U can't use functions like $kite->getQuote etc without making a call to setAccessToken ..
So basically on top of ur page it should be in place .. below tht u can work on ur code ..
$accesstoken=$adminline['accesstoken']; $apikey=$adminline['apikey']; $kite = new KiteConnect($apikey);
Is there any way we can use the API without manually login? Ex. I want to get the live stock price. Its working properly in the script. But the issue is that need to login manually. Now we give the solution to our client but technically its not feasible to ask him to login manually everyday.
Is there something like auth method? Please advice. Thanks in advance.
file_to_dump_file = open(config.KITE_OBJECT_FILE, "wb")
dill.dump(kite, file_to_dump_file) # kite being the object you set access token to
file_to_dump_file.close()
Store it like this after loading the access token
No, access_token doesn't expire after every API request. Once you have generated access_token, store it in variable and keep using it for other API calls throughout(until performing logout or fresh login).
Access token once received never expires for 24 hours untill its flushed and cleaned by zerodha daily in morning at around 7:30. You can store that token and reuse.
Thanks
Regards,
Nikhil Bansal
Tritan Solutions Pvt. Ltd.
i suspect you might have issues due to global/local values, please check your codes once again, may be data path from access generated to access expiry will give you where you went wrong.....
$output = "json_token.json";
$access_token = $_GET['request_token'];
echo $access_token;
$json['access_token'] = $access_token;
$json = json_encode($json);
file_put_contents($output, $json );
?>
This is the code I'm receiving and storing the data in the access_token in JSON. When i consume the access token the buyorder example.php . It is not working at all.
We are not sure whether it is working correctly.
include dirname(__FILE__)."/kiteconnect.php";
$kite = new KiteConnect("access token here");
?>
Could someone provide actual code to store the access token or refersh it.
$apikey=$adminline['apikey'];
$rtok=$_GET['request_token'];
$kite = new KiteConnect($apikey);
$url = $kite->getLoginURL();
if($rtok=="")
{
header("Location: $url");
exit;
}
else
{
$user = $kite->generateSession($rtok, $adminline['apisecretkey']);
$userdb=serialize($user);
$atok = $user->access_token;
$kite->setAccessToken($accesstoken);
$insert=mysqli_query($link,"update config_settings set accesstoken='".$atok."', userdetails='".$userdb."'");
Now with accesstoken in database .. U can fetch whtever data u want from the API feed ..
Not sure where is the issue.
For example lets say now the token is stored in ur database.. so to start using the api u have to declare a new instance as below .. and once it is done than only u can use lib functions they have given .. U can't use functions like $kite->getQuote etc without making a call to setAccessToken ..
So basically on top of ur page it should be in place .. below tht u can work on ur code ..
$accesstoken=$adminline['accesstoken'];
$apikey=$adminline['apikey'];
$kite = new KiteConnect($apikey);
$kite->setAccessToken($accesstoken);
$kt=$kite->getQuote(["738561"]);
thanks in advance!!
Is there any way we can use the API without manually login? Ex. I want to get the live stock price. Its working properly in the script. But the issue is that need to login manually. Now we give the solution to our client but technically its not feasible to ask him to login manually everyday.
Is there something like auth method? Please advice. Thanks in advance.