@mudit236 @babitakundu It appears it is updated now. Please try - pip install smartapi-python --upgrade
Posts made by aj_Brk
-
RE: Guide to secure your SmartAPI Account with two factor authentication
-
RE: Guide to secure your SmartAPI Account with two factor authentication
@gokul try the latest library - pip install smartapi-python --upgrade . It appears the new version is live now
-
RE: Guide to secure your SmartAPI Account with two factor authentication
@Ashok Actually you are right it works most of the time , but for those rare instances where by the time your request went and it expired on server side , i had added retry. It happened to me once perhaps due to slow code execution or internet.
-
RE: Guide to secure your SmartAPI Account with two factor authentication
@milind017 try with this condition
if not data['message'].contains('Invalid totp'):
break -
RE: Guide to secure your SmartAPI Account with two factor authentication
@milind017 I see that you have put condition in if data['status'] , is it going in retry at all ?
-
RE: Guide to secure your SmartAPI Account with two factor authentication
@babitakundu i guess you have to manually download the repo and run python setup.py install. I dont see the code yet updated on pip
-
RE: Guide to secure your SmartAPI Account with two factor authentication
@Ashok what i meant is you can't get this secret by just username and password as Anil is asking. One has to go to enable otp page to get this code one time.
-
RE: Guide to secure your SmartAPI Account with two factor authentication
@admin i too had to build the new code manually. Can you get the code merged to main?
-
RE: Guide to secure your SmartAPI Account with two factor authentication
@ivar i don't think you need to paas totp everytime. I tested get profile and other apis. It is working like before. Only login has changes.
-
RE: Guide to secure your SmartAPI Account with two factor authentication
@anil_patel i don't think that is possible as the secret is generated by angel servers, logic of which is not shared. We can't do this without secret shared by them.
-
RE: Guide to secure your SmartAPI Account with two factor authentication
@imakr shared the code in the forum. Uses pyotp library
-
RE: Guide to secure your SmartAPI Account with two factor authentication
@babitakundu are you providing 4 fields. It only needs 3. I didnt face this exception.
-
RE: Guide to secure your SmartAPI Account with two factor authentication
@anil_patel I generated it here - http://smartapi.angelbroking.com/enable-totp . It is printed below QR code
-
RE: Guide to secure your SmartAPI Account with two factor authentication
@gautamnaik1994 I have provided a sample code below. You can give it a shot. Worked for me .
-
RE: Guide to secure your SmartAPI Account with two factor authentication
Hi folks
If anyone looking for automating totp part , you can use the following python sample for the same. The secret here comes after validating on enable-totp url .
from smartapi import SmartConnect # or from smartapi.smartConnect import SmartConnect
import pyotpimport smartapi.smartExceptions(for smartExceptions)
create object of call
obj = SmartConnect(api_key="your api key here ")
login api call
totp = pyotp.TOTP(s='secret key in qr uri after qr generation')
attempts = 5
while attempts > 0:
attempts = attempts-1
data = obj.generateSession("Your client id ", "your password ", totp.now())
if not data['message'].contains('Invalid totp'):
break
time.sleep(2) ###rate limiting might block if we try immediatelyrefreshToken = data['data']['refreshToken']