Missing request_token

mithunthakur
Its error show when i try to connect. What should i do

Notice: Undefined index: request_token in /home/public_html/content/6-php/zarodha.php on line 9
Request Token is: CheckSum is: 177657252a5b21ee2170c7aef6e8fc2397577eeea3fd1f2261e05b40a68e8b05Authentication failed: Missing request_token
Fatal error: Uncaught InputException (400) 'Missing request_token' thrown in /home/public_html/content/6-php/kiteconnect.php on line 668
  • tonystark
    Did you get the request token after login? How are you providing request token to your PHP script?
  • mithunthakur
    mithunthakur edited January 2018
    How i can get token. i have not any request token
  • tonystark
    Check out example written here. You can also read about login flow here.
  • mithunthakur
    mithunthakur edited January 2018
    I use the code
    <pre class="CodeBlock"><code><?php
    include 'kiteconnect.php';

    //Hard coded values
    $api_key = "******";
    $secret_key = "*******";

    // Incoming from the redirect.
    $request_token = $_GET["request_token"];
    echo "
    Request Token is: ".$request_token;

    $checksum = hash("sha256", $api_key . $request_token . $secret_key);
    echo "
    CheckSum is: ".$checksum;

    $kite = new KiteConnect($api_key);
    try {
    $user = $kite->requestAccessToken($request_token, $secret_key);
    echo "Authentication successful. \n";
    print_r($user);
    $kite->setAccessToken($user->access_token);
    } catch(Exception $e) {
    echo "Authentication failed: ".$e->getMessage();
    throw $e;
    }
    echo $user->user_id." has logged in";

    ?>
    and error is

    Notice: Undefined index: request_token in /home/***/public_html/content/6-php/zarodha.php on line 9
    Request Token is: CheckSum is: **************************Authentication failed: Missing request_token
    Fatal error: Uncaught InputException (400) 'Missing request_token' thrown in /home/***/public_html/content/6-php/kiteconnect.php on line 668
  • tonystark
    tonystark edited January 2018
    Did you check whether URL contains request_token parameter or not? Also, try giving the parameter manually to see if it works.
  • mithunthakur
    mithunthakur edited January 2018
    how i can get request token with php. manually request token working in php it show Undefined index: request_token
  • sujith
    We just tried and it seems to be working fine if your login is successful.
  • mithunthakur
    $response = file_get_contents("https://api.kite.trade/instruments/historical/5633/minute?from=2016-12-28&to=2017-01-01&api_key=*******&access_token=".$user->access_token);

    error
    failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /home/**/public_html/content/6-php/zarodha.php on line 50
  • sujith
    It seems like historical data subscription is not active for your app.
  • mithunthakur
    then what can i do?
  • sujith
    You need to subscribe to it in order to use.
  • mithunthakur
    how i can subscribe?
  • sujith
    You can go to developers console and open your app details page, on the right, there is a section Addons. You can subscribe to historical data from that section.
  • mithunthakur
    can i get two stock with one token?
  • sujith
    Once you get access token, it is valid for the whole day. You can place any number of orders with that.
  • mithunthakur
    mithunthakur edited January 2018
    Can you tell me with only Publisher API what data i can access and other hand with Kite connect + Publisher API what data i can access can you tell me difference
  • sujith
    The Kite Publisher is just a javascript button that can be included on websites and blogs to place an order. It doesn't have access to any of the client's data.
    On the other hand, Kite Connect is the full-fledged APIs which lets you access orderbook, profile, positions, holdings, live market data and more.
  • mithunthakur
    Warning: file_get_contents(https://api.kite.trade/user/margins/equity?api_key=key&access_token=token): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in i have this error
  • sujith
    As mentioned above, Kite Publisher app can't access any APIs. You need to create a Kite Connect app.
  • mithunthakur
    i already have
  • sujith
    Are you doing login with the new login URL or old URL?
    You need to use new send authentication URL. The api key and access tokens are sent in the header and not in the URL. You can check out the new documentation for more details.
  • mithunthakur
    same working on me till yesterday today it give error
  • sujith
    sujith edited January 2018
    Kite Connect 3 request formats have changed, you can check out more details here.
  • mithunthakur
    One thing more i am creating app. still i do not use API for trading. Is there any option in api where from i can get data not live like dummy or demo so i can create my app after that i pay for live data
  • sujith
    We don't have Sandbox environment yet, we are waiting for APIs from our OMS vendor.
This discussion has been closed.