Fatal error: Uncaught PermissionException (403)

vini.jegan
vini.jegan edited July 2016 in PHP client
Authentication failed: That API call is not allowed for the authenticated user
Fatal error: Uncaught PermissionException (403) 'That API call is not allowed for the authenticated user' thrown in C:\xampp\htdocs\amibroker\kiteconnect.php on line 668

I am using Connect and zerodha id is RV0352

<?php
include dirname(__FILE__)."/kiteconnect.php";

// Initialise.
$kite = new KiteConnect("0j24vgstal8somp5");

// Assuming you have obtained the `request_token`
// after the auth flow redirect by redirecting the
// user to $kite->login_url()
try {
$user = $kite->requestAccessToken("5i6brgqbi4tskw5hvwa40t7bnjn44w0h", "xxxxxxxxxx");

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";

// Get the list of positions.
echo "Positions: \n";
print_r($kite->positions());

// Place order.
$order_id = $kite->orderPlace([
"tradingsymbol" => "INFY",
"exchange" => "NSE",
"quantity" => 1,
"transaction_type" => "BUY",
"order_type" => "MARKET",
"product" => "NRML"
], "regular");

echo "Order id is ".$order_id;

  • Kailash
    @vini.jegan You shared your api_secret in the above message. I've edited it out. Never share your API secret. I've also regenerated the secret, so please copy the new one from the developer console and try again. It should work this time.
  • vini.jegan
    Thanks its working... thank u ji
This discussion has been closed.