프론트에서 보내도록 수정해야함
This commit is contained in:
@@ -1,18 +1,42 @@
|
||||
package site.ocr.prd.contorllers;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@RestController
|
||||
public class LoginController {
|
||||
|
||||
@PostMapping("login/oauth-kakao")
|
||||
public String postMethodName(@RequestBody String entity) {
|
||||
//TODO: process POST request
|
||||
System.out.println(entity);
|
||||
return entity;
|
||||
public Map<String, Object> kakaoLogin() {
|
||||
HttpClient client = HttpClient.newHttpClient();
|
||||
Map<String, Object> returnValue = new HashMap<>();
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://kauth.kakao.com/oauth/authorize"))
|
||||
.GET()
|
||||
.header("Content-Type", "application/json")
|
||||
.build();
|
||||
try {
|
||||
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
System.out.println("response body :: " + response.body());
|
||||
returnValue.put("body", response.body());
|
||||
returnValue.put("status", response.statusCode());
|
||||
returnValue.put("headers", response.headers());
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println(e.getMessage());
|
||||
} catch (IOException e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user