auth0 / java-jwt

Java implementation of JSON Web Token (JWT)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IncorrectClaimException

Richyeoh opened this issue · comments

Checklist

  • I have looked into the Readme and Examples, and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

fun encode(iat: Long, exp: Long, uid: String): String {
    val build = JWT.create()
    build.withClaim("uid", uid)
    build.withExpiresAt(Date(System.currentTimeMillis() + EXPIRES_TIME))
    return build.sign(Algorithm.HMAC256(SECRET))
}

fun decode(token: String): DecodedJWT {
    return JWT.require(Algorithm.HMAC256(SECRET)).build().verify(token)
}

Here is my kotlin code, When I using decode fun throw an exception IncorrectClaimException

Reproduction

I using decode fun throw an exception IncorrectClaimException

Additional context

No response

java-jwt version

4.4.0

Java version

17