문제
혹시나 스프링 부트에서 Google OAuth2 소셜 로그인 기능을 구현하고, 프로덕션 도메인(https)에서 접속하였을 때 아래와 같은 증상이 발생한다면:
- Error 400: redirect_uri_mismatch
- error details를 눌러서 확인하면, Request details에 http://example.com/login/oauth2/code/google 이라고 적혀있음(http!!!)
해결
application.yml에 아래와 같이 redirect-uri를 https로 명시해준다
spring:
security:
oauth2:
client:
registration:
google:
client-id: ${GOOGLE_CLIENT_ID}
client-secret: ${GOOGLE_CLIENT_SECRET}
redirect-uri: https://example.com/login/oauth2/code/google
scope:
- profile
- email