Hi, An access token is valid for one whole day. Once you get access token, you don't have to request for it again unless you are logged out. A request token is valid for a couple of minutes and can be used only once. You should not request for access token for every run. Once you get access token store it in a file or app preferences and re-use it
@sujith : I have created a session and an access token in morning. However when i tried to use the same session in afternoon i got a : KiteException: com.zerodhatech.kiteconnect.kitehttp.exceptions.TokenException
As suggested by you i am creating a session and an access token only once for a day, but looks like the session and token does not remain active for the entire day.
Even though i logged in at around 930/10 am, this happens with me, yesterday at 3PM, i got com.zerodhatech.kiteconnect.kitehttp.exceptions.TokenException.
@sujith, After the login completion i get the access token and the authentication is successful but, soon after the code is completed executing the code i have to again re-login if i refresh the same webpage and i get the error as "Authentication failed: Token is invalid or has expired."
Please advise on how i can keep the access token, public token etc. for the session alive so that i do not have to login for each refresh.
This is bit frustrating as i am writing and testing my code. Below is my code i am working on in PHP,
actually me too facing the same issue my access_token is expiring frequently. on the other hand, my friends token remains active for the whole day we both are using the same logic and same coding. i didnt made any changes in my code and since 2 months its working perfectly. just i was required to update the token early morning daily. but since today, my token is expiring within a minute or two.
i tried it using in my localhost server(local system files), token works fine, but it expires only if i update it on my server files...
@sujith , A request token is valid for a couple of minutes and can be used only once. You should not request for access token for every run. Once you get access token store it in a file or app preferences and re-use it.
You said that token can be used only once and also mentioned that you can re-use it. Can you please clarify your statement here?
I am storing Token is local system and when I try to re-use it, it throws an exception to re-login again.
An access token is valid for one whole day. Once you get access token, you don't have to request for it again unless you are logged out.
A request token is valid for a couple of minutes and can be used only once. You should not request for access token for every run.
Once you get access token store it in a file or app preferences and re-use it
As suggested by you i am creating a session and an access token only once for a day, but looks like the session and token does not remain active for the entire day.
Can you please suggest?
com.zerodhatech.kiteconnect.kitehttp.exceptions.TokenException.
Are you sure you didn't log in to PI or NEST?
If you log out from any platform then you might be logged out everywhere.
After the login completion i get the access token and the authentication is successful but, soon after the code is completed executing the code i have to again re-login if i refresh the same webpage and i get the error as "Authentication failed: Token is invalid or has expired."
Please advise on how i can keep the access token, public token etc. for the session alive so that i do not have to login for each refresh.
This is bit frustrating as i am writing and testing my code. Below is my code i am working on in PHP,
=========================================================
// Initialise for KiteConnect
$apikey = "ABC";
$apisecret = "XYZ";
$tempkite = new KiteConnect($apikey);
if(isset($_GET["request_token"])){
$request_token = $_GET["request_token"];
//echo "Token is: ".$request_token."\n";
}else{
header("Location: ".$tempkite->getLoginURL());
exit();
}
try {
$user = $tempkite->generateSession($request_token, $apisecret);
echo nl2br("Authentication successful. \r\n \r\n");
$tempkite->setAccessToken($user->access_token);
} catch(Exception $e) {
echo "Authentication failed: ".$e->getMessage();
throw $e;
}
=========================================================
my access_token is expiring frequently. on the other hand, my friends token remains active for the whole day
we both are using the same logic and same coding. i didnt made any changes in my code and since 2 months its working perfectly. just i was required to update the token early morning daily. but since today, my token is expiring within a minute or two.
i tried it using in my localhost server(local system files), token works fine, but it expires only if i update it on my server files...
please help me brother
email [email protected]
Please read my comment about the request token.
A request token is valid for a couple of minutes and can be used only once. You should not request for access token for every run.
Once you get access token store it in a file or app preferences and re-use it.
You said that token can be used only once and also mentioned that you can re-use it. Can you please clarify your statement here?
I am storing Token is local system and when I try to re-use it, it throws an exception to re-login again.
go through this video
https://youtube.com/watch?v=wHLrMyzdgJw