API Request token not fetching session accesstoken

devajit
After Successful login the request token fetching not results ( BLANK ). I get the request token from the redirect url by GET method and use it to generate the access token like the following:

[ $zerodha_request_token = isset($_GET['request_token']) ? $_GET['request_token'] : "";

$user = $kite->generateSession($zerodha_request_token, $zerodha_secret);

print_r($user) ]

.......NO Result ( Blank )

when I print the result, it showed nothing. I deleted the old app in kite API page and created a new App with a new redirect url still no change. I am frustrated with it. Please help.
May be your system has stored the old redirect URL and ignoring any new redirect URLs
Tagged:
  • rakeshr
    rakeshr edited March 2021
    @devajit
    [ $zerodha_request_token = isset($_GET['request_token']) ? $_GET['request_token'] : "";
    Can you print captured request_token? And check if it's reading exact same request_token as in re-diect url.
  • devajit
    devajit edited March 2021

    $zerodha_request_token = isset($_GET['request_token']) ? $_GET['request_token'] : "";

    $kite = new KiteConnect($zerodha_apikey);

    try {
    $user = $kite->generateSession($zerodha_request_token, $zerodha_secret);
    $kite->setAccessToken($user->access_token);
    } catch(Exception $e) {
    echo "Authentication failed: ".$e->getMessage();
    throw $e;
    }

    echo "Request Token: " . $zerodha_request_token;
    echo "<br>";
    echo "generateSession result:";
    echo "<br>";
    print_r($user);




    I think there is nothing wrong in the process. May be your system has cached the old records( The App title and redirect URL). Although I deleted the old app but I created the new App with the same Title as "MXTRADE" but with a different redirect URL with a different domain name.

    Last domain I used was: https://www.nextlevelbot.com
    My New domain name is: https://www.mxtrade.in
    Please check and give me a solution. Thank you.
  • devajit
    I uploaded an Image showing the request token which is missing now. Did you find it ?
  • rakeshr
    @devajit
    Your code looks fine.
    $user = $kite->generateSession($zerodha_request_token, $zerodha_secret)
    If either request_token or secret value is wrong, the above call would throw exception. Are you getting any error/exception here?
  • devajit
    Api keys and App Secrets are absolutely fine. I copied and pasted them and checked multiple times. I am getting no error exception message. Just blank. No outputs.

    Is it possible that your caching system has stored my previous app's settings and complying with that or is it that one cannot change the redirect URL once set? Because the same thing had happened with my previous App also. When I set the "Redirect URL" to my localhost it worked perfectly fine but when I changed it to my live server's URL it did not work. I tested it back and forth. How come it worked with localhost and not in live server. Now when I deleted all my previous apps and freshly created a new app. The same issue persists ! Please figure out the issue because I am incurring my API fees creating new apps without any valid outcome. Thank you.
  • sujith
    @devajit,
    You don't need to create new apps. You can write to kiteconnect(at)zerodha.com for refund if you have created multiple apps.
    We don't have any issues and we don't cache the redirect URL of an app. Kite Connect APIs respond with either success response or error response, there are many production apps using Kite Connect. It is highly improbable that Kite Connect will send an empty response.
  • devajit
    Hi Sujit I do understand that its improbable but I have stated my code and screenshot of the response. There must be something which has to be taken into account. I witnessed it first hand and I am willing to share my Api credentials if you seriously want to probe the issue. As I have also mentioned that in my previous case it worked with my localhost url but with the same setup and codes it didn't work with my live server url. That means the API responded to my localhost url but not the other urls. How come?

    I really want refund as my App has still 29 days left to expire and I would like to create an app with a new name and url. Thank you
Sign In or Register to comment.