Shoonya-Dev / ShoonyaApi-py

144 stars 133 forks source link

how to start websocket using existing session token. #150

Closed bhaskarndas closed 5 months ago

bhaskarndas commented 8 months ago

Hello I am using the below code to login and at the same time it is generating session token key.

ret=api.login(userid=cred['user'], password=cred['pwd'], twoFA=TOTP, vendor_code=cred['vc'],
              api_secret=cred['apikey'], imei=cred['imei'])

I want to use the session token key to start websocket connection

so instead of using the above login code again in my example_market.py I would like to use code something like this

ret= api.set_session()

but it seems it is not viable solution.

Do you have any code example for the same.

The expected outcome is to use the session token instead of initiating login again for websocket connection file.

sohrubh commented 5 months ago

You can do the following- accessToken = ret['susertoken'] login = api.set_session(userid=config['userid'], password=config['password'], usertoken=accessToken)

Shoonya-Dev commented 5 months ago

Greetings from Shoonya!

Please follow the below-attached code:

accessToken = ret['susertoken'] login = api.set_session(userid=config['userid'], password=config['password'], usertoken=accessToken)