wrong totp, error code = AB1050
-
-
@piidus Facing same issue since two days.
-
@vardaan24 How to enable Time-based One Time Password (TOTP) ? (one-time setup)
Step 1 - Visit smartapi.angelbroking.com/enable-totp
Step 2 - Enter your Angel One client id and trading terminal password
Step 3 - Enter OTP sent to Registered email & mobile. Once OTP is entered, you will see a QR code on the screen.
Step 4 - Open the authenticator app of your choice
Step 5 - Scan the QR code generated from our site on your authenticator appHow to login to SmartAPI using password and TOTP?
Once your authenticator app scans the QR code, it will automatically generate an authentication code (called as TOTP) every 30 seconds. You are required to pass the TOTP code in our existing loginbypassword API endpoint (/rest/auth/angelbroking/user/v1/loginByPassword) by sending a new "totp" parameter via the request body.
The below request parameters illustrates how to send the client code, password and totp to authenticate and get the tokens
{
"clientcode":"your_client_code",
"password":"your_password",
"totp":"enter_the_code_displayed_on_your_authenticator_app"
} -
Error:
Order placement failed for XXXXXPE. Error: string indices must be integers
Invalid totp, error code = AB1050If you are facing above mentioned errors recently, This is due to the Implementation of totp while generating session.
The version of smartapi and websocket-client pakages should be latest. ie., smartapi-python-1.3.0 & websocket-client-1.4.1
Uninstall the existing packages and Install the latest one.
Uninstall
PS C:\Users> pip uninstall smartapi-python
Found existing installation: smartapi-python 1.2.9
Uninstalling smartapi-python-1.2.9:PS C:\Users> pip uninstall websocket-client
Found existing installation: websocket-client 1.2.1
Uninstalling websocket-client-1.2.1:
Successfully uninstalled websocket-client-1.2.1Install
PS C:\Users> pip install smartapi-python
Collecting smartapi-python
Downloading smartapi-python-1.3.0.tar.gz (13 kB)
Preparing metadata (setup.py) ... done
Successfully built smartapi-python
Installing collected packages: smartapi-python
Successfully installed smartapi-python-1.3.0PS C:\Users> pip install websocket-client
Collecting websocket-client
Downloading websocket_client-1.4.1-py3-none-any.whl (55 kB)
---------------------------------------- 55.0/55.0 kB 2.8 MB/s eta 0:00:00
Installing collected packages: websocket-client
Successfully installed websocket-client-1.4.1Cause:
Older version of SmartConnect only takes 3 values Including apikey
def generateSession(self,clientCode,password):
params={"clientcode":clientCode,"password":password}
Latest Version
def generateSession(self,clientCode,password,totp):
params={"clientcode":clientCode,"password":password,"totp":totp}