프론트에서 보내도록 수정해야함
This commit is contained in:
@@ -1,18 +1,42 @@
|
|||||||
package site.ocr.prd.contorllers;
|
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.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class LoginController {
|
public class LoginController {
|
||||||
|
|
||||||
@PostMapping("login/oauth-kakao")
|
@PostMapping("login/oauth-kakao")
|
||||||
public String postMethodName(@RequestBody String entity) {
|
public Map<String, Object> kakaoLogin() {
|
||||||
//TODO: process POST request
|
HttpClient client = HttpClient.newHttpClient();
|
||||||
System.out.println(entity);
|
Map<String, Object> returnValue = new HashMap<>();
|
||||||
return entity;
|
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