Smart API Login issue
-
Hi,
Can you please solve this issue.{"status":false,"message":"Invalid totp","errorcode":"AB1050","data":null}
-
@Moderator_3 if i directly pass the secret key it is giving error like
-
Home @sunil_modi
Can you please don't encode the string which you are getting from the totp screen.Instead of encoding please pass it directly
Regards,
SmartAPI Team -
@Moderator_3 i am doing the same still getting this error
secret_key = "f6f7faf4-7986-45-be2f-751f890b9be2"
base32_secret = base64.b32encode(secret_key.encode()).decode()
totp = pyotp.TOTP(base32_secret)
obj = SmartConnect(api_key=api_key)
data = obj.generateSession(client_id, '5437', totp.now())
-
@Moderator_3 This is what i am doing, still getting same error
secret_key = "f6f7faf4-7986-45-be2f-751f890b9be2"
base32_secret = base64.b32encode(secret_key.encode()).decode()
Generate a TOTP instance
totp = pyotp.TOTP(base32_secret).now()
-
Hello @sunil_modi
Can you please use this pyotp library
totp = pyotp.TOTP(token).now()
https://pypi.org/project/pyotp/Regards,
SmartAPI Team -
@Moderator_3 I am not able to enable totp from ui and when i try to generate it using secret key i am getting Error: Invalid totp.
-
Following is the code. I have entered IP address, public IP address, mac address, client id, pin, API key and totp correctly. Still I am getting error. The following code is from API Documentation. I have pasted the error in the end.
import http.client
import mimetypes
conn = http.client.HTTPSConnection(
"apiconnect.angelbroking.com"
)
payload = "{\n"clientcode":"CLIENT_ID"
,\n"password":"CLIENT_PIN"\n
,\n"totp":"TOTP_CODE"\n}"
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-UserType': 'USER',
'X-SourceID': 'WEB',
'X-ClientLocalIP': 'CLIENT_LOCAL_IP',
'X-ClientPublicIP': 'CLIENT_PUBLIC_IP',
'X-MACAddress': 'MAC_ADDRESS',
'X-PrivateKey': 'API_KEY'
}
conn.request(
"POST", "/rest/auth/angelbroking/user/v1/loginByPassword", payload, headers)res = conn.getresponse()
data = res.read()
print(data.decode("utf-8")){"status":false,"message":"Invalid totp","errorcode":"AB1050","data":null}
-
@Moderator_3
I am using trading api -
Hello @shreyas2290
Can you please provide which API you are using for the same
Regards,
SmartAPI Team