Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ websocket_client
./dist/NorenRestApiPy-0.0.20-py2.py3-none-any.whl
pandas
pyyaml
pyotp
load_dotenv
21 changes: 15 additions & 6 deletions test_api.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
from api_helper import ShoonyaApiPy
import logging
from dotenv import load_dotenv

#enable dbug to see request and responses
logging.basicConfig(level=logging.DEBUG)

#start of our program
api = ShoonyaApiPy()

#credentials
user = <uid>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this not merged yet?
the user variable is not used
when api.login is called, userid is assigned a value from uid which is not defined

pwd = <password>
factor2 = <2nd factor>
vc = <vendor code>
app_key = <secret key>
#create .env file to securely access user credentials in program
load_dotenv('/home/akash/Documents/Projects/.env')
Copy link
Copy Markdown

@TheCodeArtist TheCodeArtist Nov 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not hardcode stuff from your local setup.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even it better if it can initialize from user env. that means system variable

what do you think

Copy link
Copy Markdown

@softashu softashu Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes that way
pwd = os.getenv('shoonya_api_pwd')


#totp from shoonya dashboard security totp section
Copy link
Copy Markdown

@TheCodeArtist TheCodeArtist Nov 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not clear what this is referring to.

Is this suggesting to fetch the value of totp from some webpage/URL?
If yes, maybe mention the exact details here.
(including a format/template of what a value looks like.

token = os.getenv('totp')
otp = pyotp.TOTP(token).now()

#os.getenv() will fetch values from .env file
#credentials
uid = os.getenv('userid')
pwd = os.getenv('password')
vc = os.getenv('vendor_code')
app_key = os.getenv('api_key')
imei = <imei>
factor2 = otp
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of pushing commits with issues and separate commits to fix them,
please consider rebasing your changes into logical commits.


#make the api call
ret = api.login(userid=uid, password=pwd, twoFA=factor2, vendor_code=vc, api_secret=app_key, imei=imei)
Expand Down