Hi, I am trying the first steps of logging into the Zerodha account using API KITE CONNECT. Is there a detailed step by step process ?
The following are my step so far: ------------------------------------------------------------------------------- KiteConnect kiteSdk = new KiteConnect("eya65voe10jorwzx"); kiteSdk.setUserId("ZX2596"); String url = kiteSdk.getLoginUrl();
What value to put for xxxx and yyyyy ? kiteSdk.setUserId --> Shoudl i give my Zerodha account ID ? Should i put all of this in one set of sequential steps as the App starts in onCreate ?
Thanks Vishnu, I was able to make some progress but got an error at this line: userModel = kiteSdk.requestAccessToken("svlo1ylhol1wbuttybr5w5y7r37t30ml", "secret key");
below is error:
01-30 21:36:21.843: E/AndroidRuntime(32759): FATAL EXCEPTION: main 01-30 21:36:21.843: E/AndroidRuntime(32759): Process: jinga.fin.stock2, PID: 32759 01-30 21:36:21.843: E/AndroidRuntime(32759): java.lang.NoSuchMethodError: No static method encodeHexString([B)Ljava/lang/String; in class Lorg/apache/commons/codec/binary/Hex; or its super classes (declaration of 'org.apache.commons.codec.binary.Hex' appears in /system/framework/ext.jar) 01-30 21:36:21.843: E/AndroidRuntime(32759): at org.apache.commons.codec.digest.DigestUtils.sha256Hex(DigestUtils.java:532) 01-30 21:36:21.843: E/AndroidRuntime(32759): at com.rainmatter.kiteconnect.KiteConnect.requestAccessToken(KiteConnect.java:174) 01-30 21:36:21.843: E/AndroidRuntime(32759): at jinga.fin.stock2.LandingPage$2.onClick(LandingPage.java:109) 01-30 21:36:21.843: E/AndroidRuntime(32759): at android.view.View.performClick(View.java:4848) 01-30 21:36:21.843: E/AndroidRuntime(32759): at android.view.View$PerformClick.run(View.java:20262) 01-30 21:36:21.843: E/AndroidRuntime(32759): at android.os.Handler.handleCallback(Handler.java:815) 01-30 21:36:21.843: E/AndroidRuntime(32759): at android.os.Handler.dispatchMessage(Handler.java:104) 01-30 21:36:21.843: E/AndroidRuntime(32759): at android.os.Looper.loop(Looper.java:194) 01-30 21:36:21.843: E/AndroidRuntime(32759): at android.app.ActivityThread.main(ActivityThread.java:5706) 01-30 21:36:21.843: E/AndroidRuntime(32759): at java.lang.reflect.Method.invoke(Native Method) 01-30 21:36:21.843: E/AndroidRuntime(32759): at java.lang.reflect.Method.invoke(Method.java:372) 01-30 21:36:21.843: E/AndroidRuntime(32759): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1033) 01-30 21:36:21.843: E/AndroidRuntime(32759): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:828)
Please refer to the Java documentation: https://kite.trade/docs/javakiteconnect/
All the methods and its arguments are explained well there.
For requestAccessToken, it takes two parameters:
1. requestToken - received from login process.
2. apiSecret - which is unique for each app.
setUserId is to set the zerodha user id in current context. You can see the test code for reference:
https://github.com/rainmattertech/javakiteconnect/blob/master/sample/src/Test.java
Thanks
userModel = kiteSdk.requestAccessToken("svlo1ylhol1wbuttybr5w5y7r37t30ml", "secret key");
below is error:
01-30 21:36:21.843: E/AndroidRuntime(32759): FATAL EXCEPTION: main
01-30 21:36:21.843: E/AndroidRuntime(32759): Process: jinga.fin.stock2, PID: 32759
01-30 21:36:21.843: E/AndroidRuntime(32759): java.lang.NoSuchMethodError: No static method encodeHexString([B)Ljava/lang/String; in class Lorg/apache/commons/codec/binary/Hex; or its super classes (declaration of 'org.apache.commons.codec.binary.Hex' appears in /system/framework/ext.jar)
01-30 21:36:21.843: E/AndroidRuntime(32759): at org.apache.commons.codec.digest.DigestUtils.sha256Hex(DigestUtils.java:532)
01-30 21:36:21.843: E/AndroidRuntime(32759): at com.rainmatter.kiteconnect.KiteConnect.requestAccessToken(KiteConnect.java:174)
01-30 21:36:21.843: E/AndroidRuntime(32759): at jinga.fin.stock2.LandingPage$2.onClick(LandingPage.java:109)
01-30 21:36:21.843: E/AndroidRuntime(32759): at android.view.View.performClick(View.java:4848)
01-30 21:36:21.843: E/AndroidRuntime(32759): at android.view.View$PerformClick.run(View.java:20262)
01-30 21:36:21.843: E/AndroidRuntime(32759): at android.os.Handler.handleCallback(Handler.java:815)
01-30 21:36:21.843: E/AndroidRuntime(32759): at android.os.Handler.dispatchMessage(Handler.java:104)
01-30 21:36:21.843: E/AndroidRuntime(32759): at android.os.Looper.loop(Looper.java:194)
01-30 21:36:21.843: E/AndroidRuntime(32759): at android.app.ActivityThread.main(ActivityThread.java:5706)
01-30 21:36:21.843: E/AndroidRuntime(32759): at java.lang.reflect.Method.invoke(Native Method)
01-30 21:36:21.843: E/AndroidRuntime(32759): at java.lang.reflect.Method.invoke(Method.java:372)
01-30 21:36:21.843: E/AndroidRuntime(32759): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1033)
01-30 21:36:21.843: E/AndroidRuntime(32759): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:828)
Can you please check why this error ?
Checkout this thread.
Can you point me to a solved example ?