JWT tocken init sdk errorcode=1

HashMap<String,Object> header=new HashMap<>();
header.put(“alg”, “HS256”);
header.put(“typ”, “JWT”);

    Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
    long time = calendar.getTime().getTime() ;
    calendar.add(Calendar.YEAR,1);
    long time2 =calendar.getTime().getTime();
    
    try {
        String jwt=Jwts.builder().setHeader(header).
                claim("appKey",SDK_KEY).
                claim("iat",time).
                claim("exp",time2).
                claim("tokenExp",time2).
                signWith(SignatureAlgorithm.HS256,SDK_SECRET.getBytes("UTF-8")).
                compact();
        Log.d("TAG", "onCreate: jwt5555 = "+jwt);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

Metting sdk init result is error ,errorCode =1
sdk visontion is 5.14

No pm to help look at this problem

@abc2353319759 , errorcode=1 might be related to the timestamp.

Could you try setting IAT to now, and EXP to 35-60 minutes from now?
The requirement is EXP has to be minimally 30 mins from IAT, but to avoid errors caused by time drifting, or slight accuracy difference, try to use 35-60 mins

Let me know if it works. If it does not, please tag me in your reply

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.