Invalid TOTP


  • Hi, I m getting null user and invalid totp , below is complete error log.

    {"sourceID":"WEB","clientPublicIP":"49.43.99.128","macAddress":"0A-00-27-00-00-19","userType":"USER","clientLocalIP":"192.168.0.106","accept":"application/json"}***************************
    {"data":null,"message":"Invalid totp","errorcode":"AB1050","status":false}JSONObject["data"] is not a JSONObject (class org.json.JSONObject$Null : null).
    Exception in thread "main" java.lang.NullPointerException: Cannot invoke "com.angelbroking.smartapi.models.User.getAccessToken()" because "user" is null
    at MainClass.main(MainClass.java:22)
    Disconnected from the target VM, address: '127.0.0.1:54973', transport: 'socket'

    Pls help, i rechecked my totp and it is valid and there is no error.


  • The error suggests a null user object and an invalid TOTP (Time-Based One-Time Password). Verify TOTP correctness and check the user object initialization in your code, as it seems to be null, leading to a NullPointerException. If TOTP is valid, focus on user object instantiation to resolve the issue


  • Hello @Ankur-Jain ,

    Apologies for delayed response and inconvenience is regretted.
    Can you provide your client code, request and response and date and time when you faced this issue? Please share the above details to smartapi@angelbroking.com.
    Thank you.

    Regards
    SmartAPI Team


  • You can add below code to get the correct TOTP

    GoogleAuthenticator gAuth = new GoogleAuthenticator();
    int totp = gAuth.getTotpPassword(secretKey);
    

    and below dependency from https://github.com/wstrange/GoogleAuth

    <dependency>
    	<groupId>com.warrenstrange</groupId>
    	<artifactId>googleauth</artifactId>
    	<version>1.4.0</version>
    </dependency>