Error for Authentication

vilassninawe

I have followed belows steps but got error.

1. To get requst_token:
https://kite.trade/connect/login?api_key=vljy89p4oft21dnx

2. Response received:
https://software-skills.blogspot.in/2016/02/stock-picks.html?&status=success&request_token=481sa061s513v6bt72485pde8f4lotmm

3. Authentication: (Executing below request through javascript from html page - trade.html from desktop)
https://api.kite.trade/session/token?api_key=vljy89p4oft21dnx&request_token=481sa061s513v6bt72485pde8f4lotmm&checksum=36de7c28d8e592390b3778d7e52209f5e98b41ee3c5b641d12d0ade81cefa4c9

Created checksum from http://www.xorbin.com/tools/sha256-hash-calculator. SHA-256 hash of (api_key + request_token + api_secret)


trade.html:





var http = new XMLHttpRequest();
var url = "https://api.kite.trade/session/token"
var params = "api_key=vljy89p4oft21dnx&request_token=481sa061s513v6bt72485pde8f4lotmm&checksum=36de7c28d8e592390b3778d7e52209f5e98b41ee3c5b641d12d0ade81cefa4c9";
http.open("POST", url, true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");

http.onreadystatechange = function()
{
if(http.readyState == 4 && http.status == 200)
{
alert(http.responseText);
}
}
http.send(params);







Getting error:
{"status": "error", "message": "Route not found", "error_type": "GeneralException"}


My goal is to query below url which needs access_token.
"https://api.kite.trade/instruments/NSE/INFY?api_key=xxx&access_token=yyy"

Plz help me to solve this issue.

Thanks in Advance.
  • vilassninawe
    Also tried below command from Ubuntu terminal.

    curl https://api.kite.trade/session/token -d "api_key=vljy89p4oft21dnx" -d "request_token=pb9ntrhmmi3fnv4eusp6ib7c3ne1f387" -d "checksum=8f232ca9316c1544131f1c9e7eb1462dcb8dd73882edf0c927b3476d387681cb"

    But, received same error.
  • sumit.ssr207
    Even I am stuck with 'Route not found' exception even after following everything mentioned in the guide.

    Let me know if you find any solution to this.
  • Kailash
    I copy-pasted the curl command you mentioned above as it is, and it works. There is no 404 Route exception.
    :~ $ curl https://api.kite.trade/session/token -d "api_key=vljy89p4oft21dnx" -d "request_token=pb9ntrhmmi3fnv4eusp6ib7c3ne1f387" -d "checksum=8f232ca9316c1544131f1c9e7eb1462dcb8dd73882edf0c927b3476d387681cb"
    Response:
    {"status": "error", "message": "Invalid session credentials", "error_type": "TokenException"}
  • vilassninawe
    Hi Kailash,

    Error 'Route not found' is solved using different internet connection/proxy for curl command line.

    But, from html page I get following error:

    Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.kite.trade/session/token. (Reason: CORS header 'Access-Control-Allow-Origin' missing).

    Thanks.
  • Golz
    I am receiving the exact same error -
    On the browser -
    {"status": "error", "message": "Route not found", "error_type": "GeneralException"}
    Using curl-
    {"status": "error", "message": "Invalid session credentials", "error_type": "TokenException"}
    Please let me know how to fix this!
  • Golz
    Found the solution -
    1. Go to https://kite.trade/connect/login?api_key=xxx
    2. Login
    3. Obtain the request_token. Important: This token is generated new every time
    4. Call the curl https://api.kite.trade/session/token -d ... command with the new request_token & new checksum values.
  • Vivek
    closing the thread
This discussion has been closed.