[Spring] JWT Access Token 파싱안되는 오류 (Feat. Signed Claims JWSs are not supported.)

하스레·2023년 1월 23일
0

오류 설명

다음 코드를 통해 JWT access token을 파싱하려고 했으나, exception이 발생하며 계속 실패했다.

Jws<Header, Claims> claims = Jwts.parser().setSigningKey(secretKey).parseClaimsJwt(token);

공통적으로 Access Token에서 유저 정보를 얻으려고 다음 코드를 사용했을 때도 오류가 발생했다.

Jwts.parser().setSigningKey(secretKey).parseClaimsJwt(token).getBody().getSubject();

오류

Signed Claims JWSs are not supported.

오류 해결

서치를 통해 발견한 방법으로, parseClaimsJwt() -> parseClaimsJws()로 수정하니 잘 동작했다!

Jws<Header, Claims> claims = Jwts.parser().setSigningKey(secretKey).parseClaimsJwt(token);

참고
https://chiki-cha.tistory.com/m/110

profile
Software Developer

0개의 댓글