diff --git a/src/main/java/com/whereyouad/WhereYouAd/domains/advertisement/presentation/GoogleAdOAuthController.java b/src/main/java/com/whereyouad/WhereYouAd/domains/advertisement/presentation/GoogleAdOAuthController.java index 135ccc11..f847a35b 100644 --- a/src/main/java/com/whereyouad/WhereYouAd/domains/advertisement/presentation/GoogleAdOAuthController.java +++ b/src/main/java/com/whereyouad/WhereYouAd/domains/advertisement/presentation/GoogleAdOAuthController.java @@ -12,11 +12,12 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; -import jakarta.servlet.http.HttpServletResponse; import org.springframework.web.util.UriComponentsBuilder; +import com.whereyouad.WhereYouAd.global.response.DataResponse; import java.io.IOException; import java.net.URI; +import java.util.Map; import java.util.UUID; @RestController @@ -42,8 +43,7 @@ public class GoogleAdOAuthController implements GoogleAdOAuthDocs { // 구글 연동 로그인 화면으로 리다이렉트 @GetMapping("/login") - public ResponseEntity redirectToGoogleAuth(@RequestParam("orgId") Long orgId, @AuthenticationPrincipal(expression = "userId") Long userId, - HttpServletResponse response) throws IOException { + public ResponseEntity>> redirectToGoogleAuth(@RequestParam("orgId") Long orgId, @AuthenticationPrincipal(expression = "userId") Long userId) { String stateToken = UUID.randomUUID().toString(); String rawState = userId + "_" + orgId; @@ -59,12 +59,7 @@ public ResponseEntity redirectToGoogleAuth(@RequestParam("orgId") Long org "&prompt=consent" + "&state=" + stateToken; - URI location = URI.create(authUrl); - - return ResponseEntity - .status(HttpStatus.FOUND) - .location(location) - .build(); + return ResponseEntity.ok(DataResponse.from(Map.of("redirectUrl", authUrl))); } @GetMapping("/callback") diff --git a/src/main/java/com/whereyouad/WhereYouAd/domains/advertisement/presentation/docs/GoogleAdOAuthDocs.java b/src/main/java/com/whereyouad/WhereYouAd/domains/advertisement/presentation/docs/GoogleAdOAuthDocs.java index 2fdf1b3d..0cf2fc6e 100644 --- a/src/main/java/com/whereyouad/WhereYouAd/domains/advertisement/presentation/docs/GoogleAdOAuthDocs.java +++ b/src/main/java/com/whereyouad/WhereYouAd/domains/advertisement/presentation/docs/GoogleAdOAuthDocs.java @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestParam; import java.io.IOException; +import java.util.Map; public interface GoogleAdOAuthDocs { @@ -19,9 +20,8 @@ public interface GoogleAdOAuthDocs { "인증이 완료되면 사전에 등록된 콜백(callback) URI로 인증 코드(code)와 상태 값(state)이 반환됩니다." ) @GetMapping("/login") - ResponseEntity redirectToGoogleAuth(@Parameter @RequestParam("orgId") Long orgId, - @Parameter(hidden = true) @AuthenticationPrincipal(expression = "userId") Long userId, - HttpServletResponse response) throws IOException; + ResponseEntity>> redirectToGoogleAuth(@Parameter @RequestParam("orgId") Long orgId, + @Parameter(hidden = true) @AuthenticationPrincipal(expression = "userId") Long userId); @Operation( summary = "구글 OAuth 인증 콜백 및 리프레시 토큰 발급",