osparamatrix / ks-orderapi-python

47 stars 59 forks source link

is there any sample code ? #32

Open keerthankumar opened 3 years ago

keerthankumar commented 3 years ago

spent an hour running the first line of the code, to get a client.

client = ks_api.KSTradeApi(access_token = "", userid = "", \
                consumer_key = "", ip = "127.0.0.1", app_id = "")

I'm getting error - Traceback (most recent call last): File "d:/gitlab/one_algo/del/kotak_test.py", line 9, in client = ks_api.KSTradeApi(access_token = "a11ac633-9112-3c74-9df1-d87a95c3f50c", userid = "KEE93_11", \ File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\ks_api.py", line 24, in init session_init_res = ks_api_client.SessionApi(self.api_client).session_init(self.userid, \ File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 397, in session_init return self.session_init_with_http_info(userid, consumerKey, ip, appId, **kwargs) # noqa: E501 File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 510, in session_init_with_http_info return self.api_client.call_api( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 354, in call_api return self.__call_api(resource_path, method, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 173, in call_api raise e File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 166, in call_api response_data = self.request( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 380, in request return self.rest_client.GET(url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 220, in GET return self.request("GET", url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 214, in request raise ApiException(status = r.status, reason = r.reason, body = r.data) ks_api_client.exceptions.ApiException: (401) Reason: Unauthorized HTTP response body: {"fault":{"code":900901,"message":"Invalid Credentials","description":"Access failure for API: /apim/session/1.0, version: 1.0 status: (900901) - Invalid Credentials. Make sure you have provided the correct security credentials"}}

kalilinux-png commented 3 years ago

first of all you need to know how all this workes then only you can move forward open the link below

  1. https://tradeapi.kotaksecurities.com
  2. clear all the application you already had
  3. go to application option in top left corner and create the new application just one
  4. add the field of per token quota as unlimited
  5. in left side you will see and option subscription click it
  6. in the center you will see a add subscription option
  7. subscribe all the api's with unlimited policy
  8. then go a step back
  9. in the left most side you will see the option of production keys select it
  10. then you will see the manage option click on it
  11. there you will get the consume key and you should generate the acces token with unlimited exipry 11 open up you python ide 12 client = ks_api.KSTradeApi(access_token = "", userid = "", \ consumer_key = "", ip = "127.0.0.1", app_id = "") acces_token=that you generated ,useid = is the username , consume key that you will get from api website app_id = the name of the app you created at the start

IF STILL THE CASE IS NOT SOLVED LET ME KNOW I WILL UPLOAD A VIDEO

keerthankumar commented 3 years ago

Thanks for the prompt response. I was able to generate the client object.

But one question here regarding the access code -

client.session_2fa(access_code = "")

  1. Is this the same access code we use https://www.kotaksecurities.com/login_indusind.html
  2. is there any way to generate access_code programmatically rather than generating it manually?
kalilinux-png commented 3 years ago

ACCES CODE IS THE OTP WHICH YOU WILL RECEIVE ON YOUR REGISTERED MOBILE NO IF YOU HAVE A TRADING ACCOUNT WITH KOTAK SECURITIES ... LET ME KNOW IF IT SOLVE OR NOT SOLVE'S YOU ISSUE

On Wed, Aug 18, 2021 at 7:39 AM keerthankumar @.***> wrote:

Thanks for the prompt response. I was able to generate the client token.

But one question here regarding the access code -

client.session_2fa(access_code = "")

  1. Is this the same access code we use https://www.kotaksecurities.com/login_indusind.html
  2. is there any way to generate access_code programmatically rather than generating it manually?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/osparamatrix/ks-orderapi-python/issues/32#issuecomment-900757301, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUCXTCSPDALV5TESQJZ4VTT5MI6PANCNFSM5CJXUH6A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

kalilinux-png commented 3 years ago

yes there is an automatic way also : before login to website you should run your code first if the code works all fine then you will get your access code on registered mobile no you don't have to do any extra work manually for ex : case 1 : you logged in the website using manual method and generated access code then no access code will be generated next time if you run you code case 2 : if you run you code on a next ( 24-hr gap is must ) day and first you run your code in this case your access code will be generated automatically

NOTE : TO GENERATE ACCES CODE BY CODE RUN THE CODE FIRST BEFORE GOING TO WEBSITE

On Wed, Aug 18, 2021 at 2:30 PM SHUBHAM YADAV @.***> wrote:

ACCES CODE IS THE OTP WHICH YOU WILL RECEIVE ON YOUR REGISTERED MOBILE NO IF YOU HAVE A TRADING ACCOUNT WITH KOTAK SECURITIES ... LET ME KNOW IF IT SOLVE OR NOT SOLVE'S YOU ISSUE

On Wed, Aug 18, 2021 at 7:39 AM keerthankumar @.***> wrote:

Thanks for the prompt response. I was able to generate the client token.

But one question here regarding the access code -

client.session_2fa(access_code = "")

  1. Is this the same access code we use https://www.kotaksecurities.com/login_indusind.html
  2. is there any way to generate access_code programmatically rather than generating it manually?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/osparamatrix/ks-orderapi-python/issues/32#issuecomment-900757301, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUCXTCSPDALV5TESQJZ4VTT5MI6PANCNFSM5CJXUH6A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

keerthankumar commented 3 years ago
 1.     in our response
      _case 2 : if you run you code on a next ( 24-hr gap is must ) day and first
      you run your code in this case your access code will be generated
      automatically_

      what code I should run to get access_code. ?
  1. even If it sends it still one has to go to mail/mobile and copy in the code. Can it be done on the fly ?

Keerthan

pv-ajay-thota commented 3 years ago

if you receive the access_code to your gmail, you can use gmail api to get the access code .. to generate the access code I had used selenium web browser automation to to login and generate access token.

keerthankumar commented 3 years ago

a couple of issues

code that worked yesterday started failing today. with error -

Traceback (most recent call last): File "d:/gitlab/one_algo/del/kotak_test.py", line 13, in client = ks_api.KSTradeApi(access_token = access_token, userid = "KEE93_11", \ File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\ks_api.py", line 24, in init session_init_res = ks_api_client.SessionApi(self.api_client).session_init(self.userid, \ File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 397, in session_init return self.session_init_with_http_info(userid, consumerKey, ip, appId, **kwargs) # noqa: E501 File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 510, in session_init_with_http_info return self.api_client.call_api( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 354, in call_api return self.__call_api(resource_path, method, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 173, in call_api raise e File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 166, in call_api response_data = self.request( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", li return self.rest_client.GET(url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 220, in GET return self.request("GET", url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 214, in request raise ApiException(status = r.status, reason = r.reason, body = r.data) ks_api_client.exceptions.ApiException: (401) Reason: Unauthorized HTTP response body: {"fault":{"code":900901,"message":"Invalid Credentials","description":"Invalid JWT token. Make sure you have provided the correct security credentials"}}

PS D:\gitlab\one_algo> & C:/Users/keerthan/AppData/Local/Programs/Python/Python38-32/python.exe d:/gitlab/one_algo/del/kotak_test.py Traceback (most recent call last): File "d:/gitlab/one_algo/del/kotak_test.py", line 13, in client = ks_api.KSTradeApi(access_token = access_token, userid = "KEE93_11", \ File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\ks_api.py", line 24, in init session_init_res = ks_api_client.SessionApi(self.api_client).session_init(self.userid, \ File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 397, in session_init return self.session_init_with_http_info(userid, consumerKey, ip, appId, kwargs) # noqa: E501 File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 510, in session_init_with_http_info return self.api_client.call_api( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 354, in call_api return self.__call_api(resource_path, method, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 173, in call_api raise e File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 166, in call_api response_data = self.request( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 380, in request return self.rest_client.GET(url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 220, in GET return self.request("GET", url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 214, in request raise ApiException(status = r.status, reason = r.reason, body = r.data) ks_api_client.exceptions.ApiException: (401) Reason: Unauthorized HTTP response body: {"fault":{"code":900901,"message":"Invalid Credentials","description":"Invalid Credentials. Make sure you have provided the correct security credentials"}} & C:/Users/keerthan/AppData/Local/Programs/Python/Python38-32/python.exe d:/gitlab/one_algo/del/kotak_test.pyne_algo> Traceback (most recent call last): File "d:/gitlab/one_algo/del/kotak_test.py", line 13, in client = ks_api.KSTradeApi(access_token = access_token, userid = "KEE93_11", \ File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\ks_api.py", line 24, in init session_init_res = ks_api_client.SessionApi(self.api_client).session_init(self.userid, \ File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 397, in session_init return self.session_init_with_http_info(userid, consumerKey, ip, appId, kwargs) # noqa: E501 File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 510, in session_init_with_http_info return self.api_client.call_api( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", li File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 173, in __call_api raise e ne 166, in __call_api response_data = self.request( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 380, in request return self.rest_client.GET(url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 220, in GET return self.request("GET", url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 214, in request raise ApiException(status = r.status, reason = r.reason, body = r.data) ks_api_client.exceptions.ApiException: (401) Reason: Unauthorized HTTP response body: {"fault":{"code":900901,"message":"Invalid Credentials","description":"Invalid JWT token. Make sure you have provided the correct security credentials"}}

It got resolved once I generated a new access_token. can you please explain why? do we need to generate access tokens as well every day?

kalilinux-png commented 3 years ago

a couple of issues

code that worked yesterday started failing today. with error -

Traceback (most recent call last): File "d:/gitlab/one_algo/del/kotak_test.py", line 13, in client = ks_api.KSTradeApi(access_token = access_token, userid = "KEE93_11", File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\ks_api.py", line 24, in init session_init_res = ks_api_client.SessionApi(self.api_client).session_init(self.userid, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 397, in session_init return self.session_init_with_http_info(userid, consumerKey, ip, appId, **kwargs) # noqa: E501 File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 510, in session_init_with_http_info return self.api_client.call_api( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 354, in call_api return self.__call_api(resource_path, method, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 173, in call_api raise e File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 166, in call_api response_data = self.request( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", li return self.rest_client.GET(url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 220, in GET return self.request("GET", url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 214, in request raise ApiException(status = r.status, reason = r.reason, body = r.data) ks_api_client.exceptions.ApiException: (401) Reason: Unauthorized HTTP response body: {"fault":{"code":900901,"message":"Invalid Credentials","description":"Invalid JWT token. Make sure you have provided the correct security credentials"}}

PS D:\gitlab\one_algo> & C:/Users/keerthan/AppData/Local/Programs/Python/Python38-32/python.exe d:/gitlab/one_algo/del/kotak_test.py Traceback (most recent call last): File "d:/gitlab/one_algo/del/kotak_test.py", line 13, in client = ks_api.KSTradeApi(access_token = access_token, userid = "KEE93_11", File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\ks_api.py", line 24, in init session_init_res = ks_api_client.SessionApi(self.api_client).session_init(self.userid, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 397, in session_init return self.session_init_with_http_info(userid, consumerKey, ip, appId, kwargs) # noqa: E501 File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 510, in session_init_with_http_info return self.api_client.call_api( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 354, in call_api return self.__call_api(resource_path, method, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 173, in call_api raise e File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 166, in call_api response_data = self.request( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 380, in request return self.rest_client.GET(url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 220, in GET return self.request("GET", url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 214, in request raise ApiException(status = r.status, reason = r.reason, body = r.data) ks_api_client.exceptions.ApiException: (401) Reason: Unauthorized HTTP response body: {"fault":{"code":900901,"message":"Invalid Credentials","description":"Invalid Credentials. Make sure you have provided the correct security credentials"}} & C:/Users/keerthan/AppData/Local/Programs/Python/Python38-32/python.exe d:/gitlab/one_algo/del/kotak_test.pyne_algo> Traceback (most recent call last): File "d:/gitlab/one_algo/del/kotak_test.py", line 13, in client = ks_api.KSTradeApi(access_token = access_token, userid = "KEE93_11", File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\ks_api.py", line 24, in init session_init_res = ks_api_client.SessionApi(self.api_client).session_init(self.userid, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 397, in session_init return self.session_init_with_http_info(userid, consumerKey, ip, appId, kwargs) # noqa: E501 File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 510, in session_init_with_http_info return self.api_client.call_api( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", li File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 173, in __call_api raise e ne 166, in __call_api response_data = self.request( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 380, in request return self.rest_client.GET(url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 220, in GET return self.request("GET", url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 214, in request raise ApiException(status = r.status, reason = r.reason, body = r.data) ks_api_client.exceptions.ApiException: (401) Reason: Unauthorized HTTP response body: {"fault":{"code":900901,"message":"Invalid Credentials","description":"Invalid JWT token. Make sure you have provided the correct security credentials"}}

It got resolved once I generated a new access_token. can you please explain why? do we need to generate access tokens as well every day?

basically we don't need to generate new access code everyday we just need otp everyday what would possible be wrong :

  1. you might be using access of diffrent app (delete all apps and keep only one) DO YOU WANT ME TO MAKE A YOUTUBE TUTORIAL ON THIS WHOLE API WOULD IT HELP YOU
keerthankumar commented 3 years ago
kalilinux-png commented 3 years ago
  • Please make a youtube video that would be really helpful for the initialization part. creating client object and authentication etc. where all the values need to fetch. currently, documentation is pretty unclear.

just give me few hours

kalilinux-png commented 3 years ago

a couple of issues

code that worked yesterday started failing today. with error -

Traceback (most recent call last): File "d:/gitlab/one_algo/del/kotak_test.py", line 13, in client = ks_api.KSTradeApi(access_token = access_token, userid = "KEE93_11", File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\ks_api.py", line 24, in init session_init_res = ks_api_client.SessionApi(self.api_client).session_init(self.userid, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 397, in session_init return self.session_init_with_http_info(userid, consumerKey, ip, appId, **kwargs) # noqa: E501 File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 510, in session_init_with_http_info return self.api_client.call_api( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 354, in call_api return self.__call_api(resource_path, method, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 173, in call_api raise e File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 166, in call_api response_data = self.request( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", li return self.rest_client.GET(url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 220, in GET return self.request("GET", url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 214, in request raise ApiException(status = r.status, reason = r.reason, body = r.data) ks_api_client.exceptions.ApiException: (401) Reason: Unauthorized HTTP response body: {"fault":{"code":900901,"message":"Invalid Credentials","description":"Invalid JWT token. Make sure you have provided the correct security credentials"}}

PS D:\gitlab\one_algo> & C:/Users/keerthan/AppData/Local/Programs/Python/Python38-32/python.exe d:/gitlab/one_algo/del/kotak_test.py Traceback (most recent call last): File "d:/gitlab/one_algo/del/kotak_test.py", line 13, in client = ks_api.KSTradeApi(access_token = access_token, userid = "KEE93_11", File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\ks_api.py", line 24, in init session_init_res = ks_api_client.SessionApi(self.api_client).session_init(self.userid, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 397, in session_init return self.session_init_with_http_info(userid, consumerKey, ip, appId, kwargs) # noqa: E501 File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 510, in session_init_with_http_info return self.api_client.call_api( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 354, in call_api return self.__call_api(resource_path, method, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 173, in call_api raise e File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 166, in call_api response_data = self.request( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 380, in request return self.rest_client.GET(url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 220, in GET return self.request("GET", url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 214, in request raise ApiException(status = r.status, reason = r.reason, body = r.data) ks_api_client.exceptions.ApiException: (401) Reason: Unauthorized HTTP response body: {"fault":{"code":900901,"message":"Invalid Credentials","description":"Invalid Credentials. Make sure you have provided the correct security credentials"}} & C:/Users/keerthan/AppData/Local/Programs/Python/Python38-32/python.exe d:/gitlab/one_algo/del/kotak_test.pyne_algo> Traceback (most recent call last): File "d:/gitlab/one_algo/del/kotak_test.py", line 13, in client = ks_api.KSTradeApi(access_token = access_token, userid = "KEE93_11", File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\ks_api.py", line 24, in init session_init_res = ks_api_client.SessionApi(self.api_client).session_init(self.userid, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 397, in session_init return self.session_init_with_http_info(userid, consumerKey, ip, appId, kwargs) # noqa: E501 File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api\session_api.py", line 510, in session_init_with_http_info return self.api_client.call_api( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", li File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 173, in __call_api raise e ne 166, in __call_api response_data = self.request( File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\api_client.py", line 380, in request return self.rest_client.GET(url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 220, in GET return self.request("GET", url, File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ks_api_client\rest.py", line 214, in request raise ApiException(status = r.status, reason = r.reason, body = r.data) ks_api_client.exceptions.ApiException: (401) Reason: Unauthorized HTTP response body: {"fault":{"code":900901,"message":"Invalid Credentials","description":"Invalid JWT token. Make sure you have provided the correct security credentials"}}

It got resolved once I generated a new access_token. can you please explain why? do we need to generate access tokens as well every day?

you don't need to generate acces token everyday if you set its validity to -1 check out this video for more help : https://youtu.be/JYQ0lDyIbwM

keerthankumar commented 3 years ago

Hi ,

once where you mentioned - "case 2 : if you run you code on a next ( 24-hr gap is must ) day and first you run your code in this case your access code will be generated automatically"

This doesn't really happen. to get OTP (access_code), we need to manually generate. Its shame that we cant host this API without manual intervention every day like other brokers support.

kalilinux-png commented 3 years ago

Hey @keerthankumar please wait few hours i will be uploading a video on this issues so that you can get the otp directly without manual interaction

keerthankumar commented 3 years ago

@kalilinux-png let me know if video is up

kalilinux-png commented 3 years ago

Yes @keerthankumar brother video was already uploaded sorry i forgot to put link but you can find the link here on this issue #37

kalilinux-png commented 3 years ago

@keerthankumar if you issue is not resolved in this video let me know that

keerthankumar commented 3 years ago

@kalilinux-png thanks for responding. I believe https://www.youtube.com/watch?v=UJT-pz9Vzks is the video you are referring to.

this explains how to extract the OTP from Gmail. But how to generate programmatically? as I explained in the comment above https://github.com/osparamatrix/ks-orderapi-python/issues/32#issuecomment-907552109

An elegant implementation of the problem would be, generate - OTP by a python function and return in the same program.

kalilinux-png commented 3 years ago

@keerthankumar so brother as i mentioned in comment section you was watching a wrong video the video for your use is here in the link below : https://www.youtube.com/watch?v=JYQ0lDyIbwM&t=1s

kalilinux-png commented 3 years ago

@keerthankumar if still your issue is not resolved let me know i will try my best

kalilinux-png commented 3 years ago

@keerthankumar When you will create a session by code then you otp ( generated once in 24 ) will be send to you gmail id and registered mobile no to get that otp we need to

  1. visit gmail manually
  2. watch the gmail api video
kalilinux-png commented 3 years ago

if still you are unable to login let me know or you can contact me on my gmail id we will be able to have better conversation there

keerthankumar commented 3 years ago

for the time being, ill go with a manual token system, you can close the ticket. but the better system would be as I suggested https://github.com/osparamatrix/ks-orderapi-python/issues/32#issuecomment-907764770 this might require some architecture changes. Please do give a thought to this. Even with your Gmail API solution, this is still a crude solution.

keerthankumar commented 3 years ago

appreciate your quick responses!

kalilinux-png commented 3 years ago

Yes It is a crude but this is the only option i see ? I would fell glad if you please share your idea what kind of implementation you are trying to implement using kotak api

keerthankumar commented 3 years ago

right now, I'm just testing with my statergies

keerthankumar commented 2 years ago

Hi I see that you mentioned, https://github.com/osparamatrix/ks-orderapi-python/issues/84#issue-1177522775

we can login without OTP. is that mean we can do login/generate sessions without manual intervention? is access_token generation still needed ?

kalilinux-png commented 2 years ago

Hi @keerthankumar Yes Your 100% Right We Can do login and generate sessions without manual intervention and access_token will not be needed.