Error in kiteconnect.php

aarush11
Authentication failed: Invalid session credentials
Fatal error: Uncaught TokenException (403) 'Invalid session credentials' thrown in /home/aarush11/public_html/kiteconnect.php on line 508

I am using my user id and api key,but receiving the above error. Site hosted live without SSL. fot testing dou you require ssl?. Please advice.
  • Vivek
    @aarush11 This happens when access_token is invalid. Can you please re initiate the login and get the access_token again?
  • aarush11
    Dear vivek,
    Sorry I didn't understand what you mentioned. Where am i supposed to reinitiate login ?.
  • Kailash
    You have to initiate the login flow in the browser. Please refer to the documentation -- https://kite.trade/docs/connect/v1/#login-flow

    The flow is well described and illustrated.
  • aarush11
    I am facing the error on the below code.
    // Check if the exception class is defined.
    if(class_exists($json->error_type)) {
    throw new $json->error_type($json->message, $headers["status_code"]);
    } else {
    throw new GeneralException($json->message, $headers["status_code"]);
    }
    If I comment these lines it takes me throught. But user id is not retrieved.
  • Kailash
    @aarush11 You should not comment those lines out! They are critical for proper error handling. What is the exact error message you're getting?

    If there's no user_id, it means you the request is not happening correctly.
  • aarush11
    Error same as first post. I am initialising login ftom kitelogin.php which includes api. I am passing the api key hardcoded. But receives the below error.
    Authentication failed: Invalid session credentials
    Fatal error: Uncaught TokenException (403) 'Invalid session credentials' thrown in /home/aarush11/public_html/kiteconnect.php on line 586
  • Kailash
    It seems like you are not passing the correct request token. Can you hardcode that too and try?
  • aarush11
    I have hardcorded everything and getting the below error.
    {
    "error_type": "ForbiddenError",
    "message": "Login session timed out. Please re-initiate the login.",
    "status": "error"
    }
  • aarush11
    Advances one more step. No error received..

    <?php
    include "kiteconnect.php";

    $request_token = $_GET["request_token"];

    $kite = new KiteConnect("5tcp3d8lpayuy1om");

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

    print_r("User Name".$user);

    But geting the following message

    toke...2auswzidmt24vewos2mwo271jescm484 Authentication failed: That API call is not allowed for the authenticated userUser Name
  • aarush11
    Sorry to all. I think the issue is with my app. Its publisher.
  • Vivek
    @aarush11 We had dealt with many such queries. Please search the forum before posting.
This discussion has been closed.