"Invalid `api_key` or `access_token`."

nikcar
nikcar edited July 2019 in PHP client
I have used the current Php client on github
I perform the following steps
1. Get the login URL (1st function)
<i class="Italic">public function loginlive1() {
$kite = new Kiteconnect("xxxxx");
$url = $kite->getLoginURL();
print_r($url);

}</i>
2. Login to kite
3. Get Request token
4. Set access token (2nd function)
<i class="Italic">public function loginlive2() {
$kite = new Kiteconnect("xxx");
$user = $kite->generateSession("xxx", "xxx");
$kite->setAccessToken($user->access_token);
print_r($kite);

}</i>
5. Get positions (3rd funtion)
<i class="Italic">public function index() {
$kite = new Kiteconnect("xxx");
print_r($kite->getPositions());
}</i>
After performing all the previous steps successfully I get the following error
"Invalid `api_key` or `access_token`."

Please assist
  • tonystark
    You should call $kite->setAccessToken($user->access_token); before $kite->getPositions()

    You will have to store access token inside a database(recommended) or in a file and use that for subsequent calls.
  • nikcar
    Thanks worked for me.
This discussion has been closed.