티스토리 뷰

Spring Boot 3.0.4 환경에서 OAuth2-Client 라이브러리를 적용 후 소셜 로그인을 구현하면서 이슈 하나가 발생하였는데 어떤 이슈인지 문제 원인은 무엇이고 어떻게 해결해야 하는지 말씀드리겠습니다.

 

이슈

OAuth2-Client 라이브러리를 적용 후 Access Token을 조회하려면 application.yml 파일에 spring.security.oauth2.client.registration.[id].client-authentication-method 프로퍼티에 POST를 적어줘야 하는데 POST를 적어도 401 예외가 발생합니다.

 

원인

client-authentication-method 프로퍼티에 POST로 정의하면 해당 조건문이 false가 되어 Access Token 발급 API를 호출할 때 client-secret 파라미터가 추가되지 않습니다.

 

 

버전 5.5부터 변경된 것 같습니다. Spring Boot 2.5.0 이상부터 해당됩니다.

 

 

해결

application.yml을 다음과 같이 수정합니다.

spring.security.oauth2.client.registration.[id].client-authentication-method: POST   (X)

spring.security.oauth2.client.registration.[id].client-authentication-method: client_secret_post (O)

 

 

참고

https://github.com/spring-projects/spring-security/issues/9220

 

Deprecate ClientAuthenticationMethod BASIC and POST · Issue #9220 · spring-projects/spring-security

Deprecate ClientAuthenticationMethod.BASIC and ClientAuthenticationMethod.POST in favour of ClientAuthenticationMethod.CLIENT_SECRET_BASIC and ClientAuthenticationMethod.CLIENT_SECRET_POST. This al...

github.com

 

728x90
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함