AB1050 Invalid TOTP while connect.GenerateSession
-
You are supposed to use any OTP library.
- Do you have the QR code for TOTP?
- Add OTPNet nuget in your project. (OTPNet)
- Convert TOTP QR to OTP string.
//Initialize Samart API using clientcode and password to test the code.
string totp = "2EYUVJNXYERUXPLAATDRTUHSWM";
string Client_code = "DELL2456"; //YOUR CLIENT CODE
string Password = "3456"; //YOUR PASSWORD
string api_key = "OvPZUMMM";
string JWTToken = ""; // optional
string RefreshToken = ""; // optionalSmartApi connect = new SmartApi(api_key, JWTToken, RefreshToken);
OutputBaseClass obj = new OutputBaseClass();//Login by client code and password
obj = connect.GenerateSession(Client_code, Password, totp);------Next in SmartConnetClass
/User Calls/
public OutputBaseClass GenerateSession(string clientcode, string password, string totpString)
{
OutputBaseClass res = new OutputBaseClass();
byte[] secretBytes = Base32Encoding.ToBytes(totpString);**// Create an instance of the TOTP class var totp = new Totp(secretBytes); // Get the current TOTP code string totpCode = totp.ComputeTotp();** res.status = true; res.http_code = "200"; try { AngelTokenResponse agr = new AngelTokenResponse(); string URL = APIURL + "/rest/auth/angelbroking/user/v1/loginByPassword"; string PostData = "{\"clientcode\":\"" + clientcode + "\",\"password\":\"" + password + "\",\"totp\":\"" + **totpCode** + "\"}";
If required, let me know, I can push entire code to GitHub
-
I have revamped c# sdk version and have uploaded it to below link. This version works with totp. Here is the link :https://github.com/piyush-r-pub/SmartAPI_AO. How to use it: https://github.com/piyush-r-pub/SmartAPI_AO/wiki. Please let me know if you face any issues or need any help.
-
@fcoder Thanks.
I have followed your code.. and now I am facing issue with http code: AB1006 - Client is block for trading.
-
@PVRavindran I can provide you with the updated DLL. That change I made in DLL.
-
@Vishal-naykawala Please provide me the latest one dll
-
@Vishal-naykawala said in AB1050 Invalid TOTP while connect.GenerateSession:
@PVRavindran I can provide you with the updated DLL. That change I made in DLL.
Please share..
-
@Vishal-naykawala How can I give you?
share your mail id.
-
@Vishal-naykawala said in AB1050 Invalid TOTP while connect.GenerateSession:
ur mail id.
-
@Vishal-naykawala said in AB1050 Invalid TOTP while connect.GenerateSession:
are your mail
my userid at gmail . com
-
@fcoder Thanks for the library. I am facing the same issue ..."Client is blocked for trading". I am able to trade normally(manually) and also using another library, able to connect to my account.
-
Hello @amrutjk
Can you please drop a mail to smartapi@angelbroking.com with your concernRegards,
SmartAPI Team -
@Moderator_3 Never mind...sorted out the issue as it was with the code but the error pointed in different direction.
-
@sen said in AB1050 Invalid TOTP while connect.GenerateSession:
QR to OTP string.
Could you please push the entire code on GitHub