Authentication failed: Missing request_token

uniraju
While trying to use php client to login into the system, I am getting the following exception.

Authentication failed: Missing request_token
Fatal error: Uncaught InputException (400) 'Missing request_token' thrown in /Applications/MAMP/htdocs/kiteconnect.php on line 586

The code used is

<?php
include "kiteconnect.php";

$request_token = $_GET["request_token"];
// Initialise.
$kite = new KiteConnect("firao0wl0whvqmrt");

// Assuming you have obtained the `request_token`
// after the auth flow redirect by redirecting the
// user to $kite->login_url()
echo "toke...".$request_token."\n";
try {
$user = $kite->requestAccessToken($request_token, "secret_key");

echo "Authentication successful. \n";
print_r($user);


My redirect url is http://127.0.0.1:8888


Kindly help me to resolve the above issue
  • Kailash
    @uniraju Looking into this.
  • Kailash
    The following works for me. Does your `echo` bit print out the request_token received from the redirect?

    <?php
    include "kiteconnect.php";

    $request_token = $_GET["request_token"];

    $kite = new KiteConnect("api_key");

    echo "toke...".$request_token."\n";
    try {
    $user = $kite->requestAccessToken($request_token, "SECRET");
    } catch(Exception $e) {
    echo "Authentication failed: ".$e->getMessage();
    }

    echo "Authentication successful. \n";
    print_r($user);
  • uniraju
    Hi,

    I am getting empty historical data for
    from=Fri Dec 14 11:30:00 IST 2018 to:Fri Dec 14 11:35:00 IST 2018 token=140033 min:1

    Pring downloaded candl:HLCO:0.0:0.0:0.0:0.0 absMin:doji dat...null datv:0 close:0.0
    Pring downloaded candl:HLCO:0.0:0.0:0.0:0.0 absMin:doji dat...null datv:0 close:0.0
    Pring downloaded candl:HLCO:0.0:0.0:0.0:0.0 absMin:doji dat...null datv:0 close:0.0
    Pring downloaded candl:HLCO:0.0:0.0:0.0:0.0 absMin:doji dat...null datv:0 close:0.0
    Pring downloaded candl:HLCO:0.0:0.0:0.0:0.0 absMin:doji dat...null datv:0 close:0.0

    Can you please guide me how to get the data

  • sujith
    Hi @uniraju,
    Please post new queries on new threads. It will be useful for someone else who has the same issue. Always add more description like which version of client version you are using and paste the complete stacktrace of the error.
This discussion has been closed.