szerhusenBC/jwt-spring-security-demo

Token refresh API end point throws MalformedJwtException

sivakumar-raja opened this issue · 1 comments

When the user try to refresh the token by using the /refresh API endpoint with Authorization as key and Bearer {exisiting live JWT token} as value in request header. The response from the server is

{
    "timestamp": 1510901298223,
    "status": 500,
    "error": "Internal Server Error",
    "exception": "io.jsonwebtoken.MalformedJwtException",
    "message": "Unable to read JSON value: \u0005\ufffdz\ufffd\ufffd&\u0016\ufffdr#\ufffd$\ufffd3S\u0013\"",
    "path": "/refresh"
}

This happens because in the refreshAndGetAuthenticationToken, this line is trying to call getUsernameFromToken using a value such as Bearer <your_token_here>, instead of just <your_token_here>.