0

I'm using Javalin and want to build authentication flow, with Auth0 I can make token and send it with header in request, But how I can get my User data from that token? How I can check which user is authenticated at that moment

1 Answers1

0

There are examples on the github repo https://github.com/auth0/java-jwt/blob/master/EXAMPLES.md

To get information from a token created with claims

String token = JWT.create()
    .withClaim("username-claim", "username")
    .sign(algorithm);

You can verify and get a claim by doing the following

DecodedJWT jwt = JWT.require(algorithm)
    .build()
    .verify(token);

String usernameClaim = jwt.getClaim("username-claim").asString();
nm980
  • 13
  • 1
  • 3