Open keerthankumar opened 3 years ago
first of all you need to know how all this workes then only you can move forward open the link below
IF STILL THE CASE IS NOT SOLVED LET ME KNOW I WILL UPLOAD A VIDEO
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 = "")
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 = "")
- Is this the same access code we use https://www.kotaksecurities.com/login_indusind.html
- 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 .
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 = "")
- Is this the same access code we use https://www.kotaksecurities.com/login_indusind.html
- 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 .
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. ?
Keerthan
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.
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
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
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?
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 :
- 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
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
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.
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
@kalilinux-png let me know if video is up
Yes @keerthankumar brother video was already uploaded sorry i forgot to put link but you can find the link here on this issue #37
@keerthankumar if you issue is not resolved in this video let me know that
@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.
@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
@keerthankumar if still your issue is not resolved let me know i will try my best
@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
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
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.
appreciate your quick responses!
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
right now, I'm just testing with my statergies
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 ?
Hi @keerthankumar Yes Your 100% Right We Can do login and generate sessions without manual intervention and access_token will not be needed.
spent an hour running the first line of the code, to get a client.
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"}}