OAuth2란?
- JWT를 이용해 이용해 제 3의 플랫폼 업체의 사용자 정보를 통해 사용자를 인증하는 표준 위임 인증기술
- 대다수의 서비스 업체에서 표준으로 OAuth2 방식으로 인증 서비스 제공
- 리소스 오너 : 인증을 요청하는 사용자
- 리소스 서버 : 사용자의 정보를 신뢰할 수 있는 제 3의 서비스
- 인증 서버 : 액세스 토큰을 발행하는 서버
- 애플리케이션 : 개발하는 서비스
[실습] OAuth2 설정을 통해 카카오 회원 정보 받기
Kakao Developers
카카오 API를 활용하여 다양한 어플리케이션을 개발해보세요. 카카오 로그인, 메시지 보내기, 친구 API, 인공지능 API 등을 제공합니다.
developers.kakao.com
OAuth설정(Kakao)
spring.security.oauth2.client.provider.kakao.authorization-uri=https://kauth.kakao.com/oauth/authorize
spring.security.oauth2.client.provider.kakao.user-name-attribute=id
spring.security.oauth2.client.provider.kakao.token-uri=https://kauth.kakao.com/oauth/token
spring.security.oauth2.client.provider.kakao.user-info-uri=https://kapi.kakao.com/v2/user/me
spring.security.oauth2.client.registration.kakao.client-name=kakao
spring.security.oauth2.client.registration.kakao.authorization-grant-type=authorization_code
spring.security.oauth2.client.registration.kakao.redirect-uri=http://localhost:8080/login/oauth2/code/kakao
# 카카오 - 내애플리케이션 - 요약정보 - REST API 키
spring.security.oauth2.client.registration.kakao.client-id=클라이언트 아이디
# 카카오 - 내애플리케이션 - 카카오 로그인 - 보안 - Client Secret
spring.security.oauth2.client.registration.kakao.client-secret=시크릿키
spring.security.oauth2.client.registration.kakao.client-authentication-method=client_secret_post
# 카카오 - 내애플리케이션 - 카카오 로그인 - 동의항목 - 내가 설정한 ID값(자주 바뀌니깐 주의)
spring.security.oauth2.client.registration.kakao.scope=profile_nickname, account_email
controller/MainController.java : index(), login() GetMapping
entity/UserEntity.java :