webclient
This commit is contained in:
@@ -2,6 +2,7 @@ package site.ocr.prd;
|
|||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@@ -9,7 +10,12 @@ public class WebClientConfig {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public WebClient webClient() {
|
public WebClient webClient() {
|
||||||
|
return WebClient.builder()
|
||||||
|
.defaultHeaders(httpHeaders -> {
|
||||||
|
httpHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
||||||
|
httpHeaders.set("charset", "utf-8");
|
||||||
|
})
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,8 @@ public class LoginController {
|
|||||||
requestDTO.setRedirectUri("http://localhost:9001/login/oauth-kakao");
|
requestDTO.setRedirectUri("http://localhost:9001/login/oauth-kakao");
|
||||||
requestDTO.setCode(accessToken);
|
requestDTO.setCode(accessToken);
|
||||||
LoginResponse response = new LoginService().loginService(requestDTO);
|
LoginResponse response = new LoginService().loginService(requestDTO);
|
||||||
|
System.out.println("response :: ");
|
||||||
|
System.out.println(response);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package site.ocr.prd.services;
|
package site.ocr.prd.services;
|
||||||
|
|
||||||
import java.net.http.HttpHeaders;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import site.ocr.prd.dto.LoginRequest;
|
import site.ocr.prd.dto.LoginRequest;
|
||||||
import site.ocr.prd.dto.LoginResponse;
|
import site.ocr.prd.dto.LoginResponse;
|
||||||
|
|
||||||
@@ -13,7 +11,15 @@ public class LoginService {
|
|||||||
|
|
||||||
public LoginResponse loginService(LoginRequest request) {
|
public LoginResponse loginService(LoginRequest request) {
|
||||||
|
|
||||||
|
private final WebClient webClient;
|
||||||
|
|
||||||
LoginResponse response = new LoginResponse();
|
LoginResponse response = new LoginResponse();
|
||||||
|
response = webClient.post()
|
||||||
|
.uri("https://kauth.kakao.com/oauth/token")
|
||||||
|
.bodyValue(request)
|
||||||
|
.retrieve()
|
||||||
|
.bodyToMono(LoginResponse.class)
|
||||||
|
.block();
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user