Can anyone help me with LOG-IN from a java standalone program

rajeshreddyrr@gmail.com
Hi,

I have below program to connect to Kite APIs.
URL u = new URL("https://kite.trade/connect/login?api_key=");

HttpsURLConnection http = (HttpsURLConnection)u.openConnection();

http.setAllowUserInteraction(true);
http.setRequestMethod("GET");
http.connect();

I am getting a certification exception
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Can anyone help me to avoid this.

Rajesh
  • Kailash
    @rajeshreddyrr@gmail.com this is not correct. The login url is meant to be opened in a browser or a webview. You are sending a GET request using an HTTP client.
  • rajeshreddyrr@gmail.com
    Thanks Kailash, I am getting the request_token manually from browser.
    I want to understand how long this token will be useful?
    Is there any timeout or will it get invalidated once we close browser session?

    One suggestion, please post examples some where? it will be helpful to avoid confusion for developers.
  • chaudhariapurva
    change user agent and try,use fiddler
  • Kailash
    @rajeshreddyrr@gmail.com The request_token is short live. Once you get it, you immediately have to use it for the token exchange to get the access_token. Then on, you use the access_token for all other requests.

    Once you get the access_token, the request_token becomes invalid. And no, it's not tied to the browser session.

    Also, every API is documented well in the API documentation with CURL examples. In addition, there are well documented, ready to use libraries in Python and PHP.
  • Kailash
    Kailash edited June 2016
    @rajeshreddyrr@gmail.com The request_token is short lived. Once you get it, you immediately have to use it for the token exchange to get the access_token. Then on, you use the access_token for all other requests.

    Once you get the access_token, the request_token becomes invalid. And no, it's not tied to the browser session.

    Also, every API is documented well in the API documentation with CURL examples. In addition, there are well documented, ready to use libraries in Python and PHP.
  • kumar_krishnan
    Hi Kailash, as per your comment, "The request_token is short live".What will be validity of the request token?

    I am trying to test with Java client, as soon as i get the request token and place it in a java program and try to get access_token, it is giving me error 403 forbidden
    {
    "status": "error",
    "message": "Invalid session credentials",
    "error_type": "TokenException"
    }
  • Kailash
    It's lifetime is about 5 mins. "Bad credentials" error happens if a) api_key is wrong b) request_token is wrong c) the SHA256 checksum is wrong.
Sign In or Register to comment.