Issue with Totp
-
Hi Folk, i am a novice in coding and while trying to get login into the Angle one demat via Spyder, i am getting the below error, can anyone help me, please.
[E 240421 17:17:50 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/auth/angelbroking/user/v1/loginByPassword. Error: Invalid totp. URL: https://apiconnect.angelbroking.com/rest/auth/angelbroking/user/v1/loginByPassword, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'cc:48:3a:66:10:f5', 'Accept': 'application/json', 'X-PrivateKey': 'key_secret[0]', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'clientcode': 'key_secret[2]', 'password': 'key_secret[3]', 'totp': '527069'}, Response: {'status': False, 'message': 'Invalid totp', 'errorcode': 'AB1050', 'data': None}
[E 240421 17:17:50 temp:27] {'status': False, 'message': 'Invalid totp', 'errorcode': 'AB1050', 'data': None} -
@Satnam Same here, Response: {'status': False, 'message': 'Invalid totp', 'errorcode': 'AB1050', 'data': None}
-
@Satnam are you using correct to pass onto totp code. it is simple 2 lines of code to get totp. are you using barcode id in totp. it would be around 26 words like "P1234ABC...." or similar.
import pyotp
totp= 'P123ABC' # Replace with your actual key
totp.now()you can then pass on this totp.now() in angel one to work further. this exactly what I use
-
@chetansuri Here is my code snippet
-
@mxt448 same here and totp is right i checked that. my doubts are that it more kind of a problem while establishing the connection.
-
Hello @Satnam
Please use your totp key which is generated and is this usually placed below the QR code and use this method to include totpfrom SmartApi import SmartConnect import pyotp from logzero import logger api_key = 'yourAPIKey' username = 'YourClientCode' pwd = 'YourPIN' smartApi = SmartConnect(api_key) try: token = "TOTP_String" totp = pyotp.TOTP(token).now() except Exception as e: logger.error("Invalid Token: The provided token is not valid.") raise e correlation_id = "abcde"
Regards,
SmartAPI Team
data = smartApi.generateSession(username, pwd, totp) -
@Moderator_3 Still it
does not work -
Hello @johngeorge
please use this code in your code to use a totp functionality
Regards,
SmartAPI Team