Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added set_session_token function #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

algowhizz
Copy link

Hi,
I have added a function which allows the user to pass session_token generated via curl or requests using various session_API login methods like OTT. Once session_token is generated, it can be set using client.set_session_token as :

client = ks_api.KSTradeApi(access_token = access_token, userid = user_id, 
                                        consumer_key = consumer_key, ip = kotak_ip, app_id = kotak_appId)
client.set_session_token(session_token=user_session_token)

followed by usual client operations.
I believe this is a good functionality to add because it allows user to initiate client without OTP access_code.

@jayakarthik-devices
Copy link

@algowhizz Where can i get user_session_token ? Can you guide me on that.

@algowhizz
Copy link
Author

@algowhizz Where can i get user_session_token ? Can you guide me on that.
https://github.com/algowhizz/kotakapi/blob/23c37c480d0422dbf2e185caa57132b02a84fa6f/2fa_ott_login.py
This is the code you need to use to generate the session token given by https://github.com/algowhizz/kotakapi/blob/23c37c480d0422dbf2e185caa57132b02a84fa6f/2fa_ott_login.py#L36

@jayakarthik-devices
Copy link

@algowhizz
Thanks for providing the info. This is really helpful.

One last question on this..

  1. My understanding based on the code that you shared is OTT will remain constant till we change any one of parameter like the password, consumer key, access token. So if that is changed we need to regenerate OTT.
  2. Session Token part of the python code is something i can integrate in my regular python code that will generate a new session token for every session.

Is my understanding correct.

@algowhizz
Copy link
Author

algowhizz commented Feb 2, 2022

  1. My understanding based on the code that you shared is OTT will remain constant till we change any one of parameter like the password, consumer key, access token. So if that is changed we need to regenerate OTT.

OTT needs to be generated everyday as it basically replaces the OTP that you receive via e-mail or SMS. Since it is easier to generate OTT than fetch OTP using selenium, I have written the script for automated OTT and session token generation every day.

  1. Session Token part of the python code is something i can integrate in my regular python code that will generate a new session token for every session.

Since OTT has to be generated everyday, the session token follows the OTT. So, the procedure is as simple as : generate OTT followed by session token (valid for 1 day). Then use the session token in your further code. If you dont wish to do all this, you can simply use the standard method where OTP is used to initialise ks_client.

@jayakarthik-devices
Copy link

@algowhizz
Thanks for answering the questions. This method is easier. I will take this.

@jayakarthik-devices
Copy link

@algowhizz
One more question... In the previous method where I manually give access code(OTP) and login, if I try to login again in a different system, it will automatically kill my session in previous system. But now with this method, it is not killing my previous system. How to kill a kotak session connectivity in linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants