From 3228c04c8029b9eb0c7b8d38ea42765e137ac705 Mon Sep 17 00:00:00 2001 From: DongGeon0908 Date: Tue, 30 Jul 2024 00:55:45 +0900 Subject: [PATCH] fix: requestBody -> requestParams --- .../kakao/client/SuspendableKakaoOAuthClient.kt | 12 +++++++++--- .../domain/dev/application/DevOAuthService.kt | 4 +--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/hero/alignlab/client/kakao/client/SuspendableKakaoOAuthClient.kt b/src/main/kotlin/com/hero/alignlab/client/kakao/client/SuspendableKakaoOAuthClient.kt index d1f67d8..e7ef0fb 100644 --- a/src/main/kotlin/com/hero/alignlab/client/kakao/client/SuspendableKakaoOAuthClient.kt +++ b/src/main/kotlin/com/hero/alignlab/client/kakao/client/SuspendableKakaoOAuthClient.kt @@ -4,7 +4,6 @@ import com.hero.alignlab.client.kakao.SuspendableClient import com.hero.alignlab.client.kakao.config.KakaoOAuthClientConfig import com.hero.alignlab.client.kakao.model.request.GenerateKakaoOAuthTokenRequest import com.hero.alignlab.client.kakao.model.response.GenerateKakaoOAuthTokenResponse -import org.springframework.http.MediaType import org.springframework.web.reactive.function.client.WebClient class SuspendableKakaoOAuthClient( @@ -26,8 +25,15 @@ class SuspendableKakaoOAuthClient( override suspend fun generateOAuthToken(request: GenerateKakaoOAuthTokenRequest): GenerateKakaoOAuthTokenResponse { return client .post() - .uri("/token") - .contentType(MediaType.APPLICATION_FORM_URLENCODED) + .uri("/token") { builder -> + builder + .queryParam("grant_type", "authorization_code") + .queryParam("client_id", request.clientId) + .queryParam("redirect_uri", request.redirectUri) + .queryParam("code", request.code) + .queryParam("client_secret", request.clientSecret) + .build() + } .bodyValue(request) .request() } diff --git a/src/main/kotlin/com/hero/alignlab/domain/dev/application/DevOAuthService.kt b/src/main/kotlin/com/hero/alignlab/domain/dev/application/DevOAuthService.kt index f678dec..ca27b0b 100644 --- a/src/main/kotlin/com/hero/alignlab/domain/dev/application/DevOAuthService.kt +++ b/src/main/kotlin/com/hero/alignlab/domain/dev/application/DevOAuthService.kt @@ -1,7 +1,6 @@ package com.hero.alignlab.domain.dev.application import com.hero.alignlab.client.kakao.KakaoOAuthService -import com.hero.alignlab.client.kakao.config.KakaoOAuthClientConfig import com.hero.alignlab.client.kakao.model.response.GenerateKakaoOAuthTokenResponse import com.hero.alignlab.domain.auth.model.OAuthProvider import com.hero.alignlab.domain.dev.model.response.DevOAuthCodeResponse @@ -11,7 +10,6 @@ import org.springframework.stereotype.Service @Service class DevOAuthService( private val kakaoOAuthService: KakaoOAuthService, - private val config: KakaoOAuthClientConfig.Config, ) { private val logger = KotlinLogging.logger { } @@ -25,7 +23,7 @@ class DevOAuthService( suspend fun resolveOAuth(provider: OAuthProvider, code: String): GenerateKakaoOAuthTokenResponse { return when (provider) { - OAuthProvider.kakao -> kakaoOAuthService.generateOAuthToken(code, config.redirectUrl) + OAuthProvider.kakao -> kakaoOAuthService.generateOAuthToken(code) } } }