솔적솔적

Spring Boot Security - NAVER(네이버) 로그인 완료하기 본문

Back-end/Spring Boot Security

Spring Boot Security - NAVER(네이버) 로그인 완료하기

카드값줘체리 2022. 2. 9. 22:15

 

https://developers.naver.com/main/

 

NAVER Developers

네이버 오픈 API들을 활용해 개발자들이 다양한 애플리케이션을 개발할 수 있도록 API 가이드와 SDK를 제공합니다. 제공중인 오픈 API에는 네이버 로그인, 검색, 단축URL, 캡차를 비롯 기계번역, 음

developers.naver.com

application.yml

    naver:
     client-id:아직모름
     client-secret:아직모름
     scope:
     -name
     -email
     client-name:Naver
     authorization-grant-type:authorization_code
     redirect-uri:http://localhost:8080/login/oauth2/code/naver ------>  고대로 넣어주기

application.yml

    naver:
     client-id:htghxb0Uip50vz6twKLC ------> 넣어주기
     client-secret:MJRTzZ2D5D ------------> 넣어주기
     scope:
     -name
     -email
     client-name:Naver
     authorization-grant-type:authorization_code
     redirect-uri:http://localhost:8080/login/oauth2/code/naver

하지만 오류가 발생되게 되는데, 

네이버라는 registration이 없다고 나온다.

 

application.yml

  naver:
     client-id:htghxb0Uip50vz6twKLC
     client-secret:MJRTzZ2D5D
     scope:
     -name
     -email
     client-name:Naver
     authorization-grant-type:authorization_code
     redirect-uri:http://localhost:8080/login/oauth2/code/naver
   
     provider:
      naver:
       authorization-uri:https://nid.naver.com/ouath2.0/authorze
       token-uri:https://nid.naver.com/oauth2.0/token
       user-info-uri:https://openapi.naver.com/v1/nid/me
       user-name-attribute:resposne #회원정보를 JSON으로 받은데 RESPONSE라는 키값으로 네이버를 리턴해줌

 

요기 주소로 로그인하면 네이버창이 뜬다는 것.

 

 

loginForm.html

<h1>로그인 페이지</h1>

<form action="/login" method="POST">

	<input type="text" name="username" placeholder="username"><br/>
	<input type="password" name="password" placeholder="password"><br/>

<button>로그인</button>
</form>

<a href="/oauth2/authorization/google">구글 로그인</a>
<a href="/oauth2/authorization/fackbook">페이스북 로그인</a>
<a href="/oauth2/authorization/naver">네이버 로그인</a>
<a href="/joinForm">회원가입을 아직 하지 않으셨나요?</a>

 

 

 

 

[참고] 인프런 - 스프링부트 시큐리티 & JWT 강의