PHP code for login/authentication

scorp
Can someone share the PHP script for login authentication? I need code to
a. make a get request to the login endpoint and receive the request token
b. make a post request for authentication to session/token endpoint

I am actually able to make these calls, however i am receiving {"status": "error", "message": "Invalid session credentials", "error_type": "TokenException"}

I am also certain that the values that i am posting are correct.

thanks
  • Kailash
    @scorp we'll be releasing an open source PHP library for Kite Connect shortly.

    In the meanwhile, if you paste your PHP code here, we may be able to debug.
  • scorp
    Kailash,
    I am glad to hear that you are working on an API. Do you mind sharing it right now so i can beta test it?
    thanks
    Rajnish
  • Kailash
    It's partial right now, but will be posted on our Github account once it's ready. We'll make an announcement next week once it's ready.
  • scorp
    Can you suggest the right way to get the request_token using PHP ?
  • Kailash
    After the login flow, Kite will redirect to your app's registered `redirect_url` with `?request_token=xxx in the URL`.

    Assuming your redirect_url is a PHP script, you can just use $_GET['request_token'] to get it from the query parameters in the URL.
  • scorp
    The login flow is acting weird. https://kite.trade/connect/login?api_key=MY_API_KEY has now stopped redirecting to my redirect url that is set to 127.0.0.1/index.php. It's not an https endpoint.
  • Kailash
    @scorp That is the way it works. The long url is the login page. Only after the login will it finally redirect to 127.0.0.1 with the request_token
  • sekharrockz
    sekharrockz edited May 2016
    @Kailash
    if i am using a standalone java application, how will i get the request token to my java application ? any logic to solve this issue ?

    One more thing, i have a redirect_url which is not a localhost, but it's to my web url .
  • Kailash
    Your redirect_url (website) can store the token and the Java app can communicate with it and fetch it.

    But, the best way would be to open the login flow in a WebView in Java. redirect_url can be whatever. Your Java app can watch the WebView's URL and when it changes to your expected redirect_url, you can just extract the request_token from the URL string and close the webview.
  • sekharrockz
    sekharrockz edited May 2016
    ok. i agree to it. if i give redirect url of my webview, then where will the messages go to when my orders get executed ?
  • sekharrockz
    sekharrockz edited May 2016
    ok understood. i need to watch the webview's url which will be updated when login happens.

    And redirect-url can be anything
  • Kailash
    Views are only involved in the login flow. Once you get the token after login, it's like any other HTTP/JSON API, just request/response.
Sign In or Register to comment.