1. dependency 추가

implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'io.jsonwebtoken:jjwt-api:0.10.7'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.10.7'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.10.7'
implementation 'org.springframework.security:spring-security-oauth2-client'

 

2. application.yml에 다음 내용 추가

application.yml 에 다음 내용 추가

spring:
  security:
    oauth2:
      client:
        registration:
          google:
            clientId: slkdjflsdjflsdjflsdlfkjsldf
            clientSecret: sdlfkjsldkfjsldflskdjflskd
            redirectUri: "{baseUrl}/oauth2/callback/{registrationId}"
            scope:
              - email
#              - profile
  • client id
    구글 oauth 콘솔에서 앱 만들기를 해서 얻은 클라이언트 ID
  • client secret
    구글 oauth 콘솔에서 앱 만들기를 해서 얻은 클라이언트 secret
  • redirect uri
    구글 oauth 콘솔의 승인된 리다이렉트 URI
    이전글에서 설명했으니 참고

    oauth 진행과정 중간에
    해당 URL에 code를 붙인 요청이
    내 서버로 들어오게 된다.
  • registrationId
    google, naver, kakao, facebook 등이 있다.
  • scope
    내 서버가 서드파티로부터 얻어올 정보 목록.

 

 

 

+ Recent posts