From 5506f8019f379b1e6bb3cc85ec9cc30a43b1d0fc Mon Sep 17 00:00:00 2001 From: cho Date: Mon, 26 Jan 2026 09:29:00 +0900 Subject: [PATCH] =?UTF-8?q?POST=20=ED=86=A0=ED=81=B0=EC=9A=94=EC=B2=AD,=20?= =?UTF-8?q?application/x-www-form-urlencoded=20=ED=8F=AC=EB=A7=B7=20?= =?UTF-8?q?=EC=A7=80=EC=9B=90.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/KjbMGOAuth2Controller.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eactive/eai/authserver/custom/KjbMGOAuth2Controller.java b/src/main/java/com/eactive/eai/authserver/custom/KjbMGOAuth2Controller.java index e63949a..58e3a54 100644 --- a/src/main/java/com/eactive/eai/authserver/custom/KjbMGOAuth2Controller.java +++ b/src/main/java/com/eactive/eai/authserver/custom/KjbMGOAuth2Controller.java @@ -31,6 +31,7 @@ import org.springframework.security.oauth2.provider.endpoint.TokenEndpoint; import org.springframework.security.oauth2.provider.token.TokenEnhancer; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -63,11 +64,27 @@ public class KjbMGOAuth2Controller { private TokenIssuanceLogDAO tokenIssuanceLogDAO; - @RequestMapping(value = "/mapi/oauth2/token", method = RequestMethod.POST, produces = "application/json; charset=\"UTF-8\"") + @RequestMapping(value = "/mapi/oauth2/token", method = RequestMethod.POST, consumes = "application/json", produces = "application/json; charset=UTF-8") @ResponseBody - public ResponseEntity token(@RequestBody KjbMGOAuth2AccessTokenRequest tokenRequest, + public ResponseEntity tokenJson(@RequestBody KjbMGOAuth2AccessTokenRequest tokenRequest, HttpServletRequest request, HttpServletResponse response) { - + + return issueToken(tokenRequest, request, response); + } + + @RequestMapping(value = "/mapi/oauth2/token", method = RequestMethod.POST, consumes = "application/x-www-form-urlencoded", produces = "application/json; charset=UTF-8") + @ResponseBody + public ResponseEntity tokenForm(@RequestParam Map params, HttpServletRequest request, + HttpServletResponse response) { + + KjbMGOAuth2AccessTokenRequest tokenRequest = new KjbMGOAuth2AccessTokenRequest(); + + tokenRequest.setGrantType(params.get("grant_type")); + tokenRequest.setClientId(params.get("client_id")); + tokenRequest.setClientSecret(params.get("client_secret")); + tokenRequest.setScope(params.get("scope")); + tokenRequest.setResource(params.get("resource")); + return issueToken(tokenRequest, request, response); }