java sdk TOTP
-
I am trying to login in to angel one smart api via v2.0.0 jar but unable to login due invalid totp eventhough i have extensivel checked and it is correct.
login result: {"data":null,"message":"Invalid totp","errorcode":"AB1050","status":false
any java developer who is currently working on maven or java pls help -
Hi @malhar1080p
Please share us your json request body here to verify.
-
-
I am also facing same issue but in nodejs
here is my code
async function login2(userId, password, totp1 = "") {
// Get API credentials for this user
const user = await userService.getUser("angelone", userId);
if (!user) {
throw new Error("User not found or not subscribed");
}const apiKey = user["api_key"];
const apiSecret = user["api_secret"];let { SmartAPI } = require("smartapi-javascript");
const totp = speakeasy.totp({
secret: TOTP_SECRET,
encoding: "base32",
});console.log("%s", [apiKey, userId, password, totp]);
let smart_api = new SmartAPI({
api_key: apiKey, // PROVIDE YOUR API KEY HERE
});// If user does not have valid access token and refresh token then use generateSession method
res = await smart_api.generateSession(userId, password, totp);
console.log(res);
return res;
}here is response
{
status: false,
message: 'Invalid totp',
errorcode: 'AB1050',
data: null
} -
Please do check are you passing appropriate 6 digit TOTP code from authenticator app.
-
@admin Yes i did checked i am passing correct 6 digit code from authenticator app and also it is matching with speakeasy's totp function response
-
Hi @9868072301
Are you passing 4 digit pin in password parameter ?
-
@admin Yes I do, also verified it by printing it in console you can see below line in my code
console.log("%s", [apiKey, userId, password, totp]);