Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs
    1. Home
    2. aj_Brk
    3. Posts
    A
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by aj_Brk

    • RE: Guide to secure your SmartAPI Account with two factor authentication

      @mudit236 @babitakundu It appears it is updated now. Please try - pip install smartapi-python --upgrade

      posted in General Discussion
      A
      aj_Brk
    • 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

      posted in General Discussion
      A
      aj_Brk
    • 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.

      posted in General Discussion
      A
      aj_Brk
    • RE: Guide to secure your SmartAPI Account with two factor authentication

      @milind017 try with this condition

      if not data['message'].contains('Invalid totp'):
      break

      posted in General Discussion
      A
      aj_Brk
    • 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 ?

      posted in General Discussion
      A
      aj_Brk
    • 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

      posted in General Discussion
      A
      aj_Brk
    • 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.

      posted in General Discussion
      A
      aj_Brk
    • 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?

      posted in General Discussion
      A
      aj_Brk
    • 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.

      posted in General Discussion
      A
      aj_Brk
    • 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.

      posted in General Discussion
      A
      aj_Brk
    • RE: Guide to secure your SmartAPI Account with two factor authentication

      @imakr shared the code in the forum. Uses pyotp library

      posted in General Discussion
      A
      aj_Brk
    • 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.

      posted in General Discussion
      A
      aj_Brk
    • 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

      posted in General Discussion
      A
      aj_Brk
    • 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 .

      posted in General Discussion
      A
      aj_Brk
    • 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 pyotp

      import 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 immediately

      refreshToken = data['data']['refreshToken']

      posted in General Discussion
      A
      aj_Brk