-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from DoTheZ-Team/GLUE-100-add-kakao-login-rest
GLUE-100 Feat: 이전 버전 카카오 로그인 api 복구
- Loading branch information
Showing
12 changed files
with
236 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/com/justdo/plug/auth/global/jwt/kakao/preVersion/KakaoTokenJsonData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.justdo.plug.auth.global.jwt.kakao.preVersion; | ||
|
||
import com.justdo.plug.auth.global.exception.ApiException; | ||
import com.justdo.plug.auth.global.jwt.kakao.preVersion.dto.response.KakaoTokenResponse; | ||
import com.justdo.plug.auth.global.response.code.status.ErrorStatus; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import org.springframework.web.reactive.function.client.WebClientResponseException; | ||
import reactor.core.publisher.Flux; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class KakaoTokenJsonData { | ||
private final WebClient webClient = WebClient.create(); | ||
|
||
@Value("${kakao.token_uri}") | ||
private String tokenUri; | ||
|
||
@Value("${kakao.redirect_uri}") | ||
private String redirectUri; | ||
|
||
@Value("${kakao.grant_type}") | ||
private String grantType; | ||
|
||
@Value("${kakao.client_id}") | ||
private String clientId; | ||
|
||
public KakaoTokenResponse getToken(String code) { | ||
String uri = tokenUri + "?grant_type=" + grantType + "&client_id=" | ||
+ clientId + "&redirect_uri=" + redirectUri + "&code=" + code; | ||
|
||
log.info("uri = {}", uri); | ||
|
||
Flux<KakaoTokenResponse> response = webClient.post() | ||
.uri(uri) | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.retrieve() | ||
.bodyToFlux(KakaoTokenResponse.class); | ||
|
||
return response.onErrorMap(WebClientResponseException.class, | ||
e -> new ApiException(ErrorStatus._KAKAO_TOKEN_ERROR)).blockFirst(); | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/justdo/plug/auth/global/jwt/kakao/preVersion/KakaoUserInfoJsonData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.justdo.plug.auth.global.jwt.kakao.preVersion; | ||
|
||
import com.justdo.plug.auth.global.exception.ApiException; | ||
import com.justdo.plug.auth.global.jwt.kakao.preVersion.dto.response.KakaoUserInfoResponse; | ||
import com.justdo.plug.auth.global.response.code.status.ErrorStatus; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import org.springframework.web.reactive.function.client.WebClientResponseException; | ||
import reactor.core.publisher.Flux; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class KakaoUserInfoJsonData { | ||
private final WebClient webClient = WebClient.create(); | ||
|
||
@Value("${kakao.user_info_uri}") | ||
private String userInfoUri; | ||
|
||
public KakaoUserInfoResponse getUserInfo(String token) { | ||
|
||
Flux<KakaoUserInfoResponse> response = webClient.get() | ||
.uri(userInfoUri) | ||
.header("Authorization", "Bearer " + token) | ||
.retrieve() | ||
.bodyToFlux(KakaoUserInfoResponse.class); | ||
|
||
return response.onErrorMap(WebClientResponseException.class, ex -> { | ||
return new ApiException(ErrorStatus._KAKAO_USER_INFO_ERROR);}) | ||
.blockFirst(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/justdo/plug/auth/global/jwt/kakao/preVersion/dto/JwtTokenResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.justdo.plug.auth.global.jwt.kakao.preVersion.dto; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class JwtTokenResponse { | ||
|
||
private final String accessToken; | ||
private final String refreshToken; | ||
|
||
@Builder | ||
public JwtTokenResponse(String accessToken, String refreshToken) { | ||
this.accessToken = accessToken; | ||
this.refreshToken = refreshToken; | ||
} | ||
|
||
public static JwtTokenResponse createJwtTokenResponse(String accessToken, String refreshToken) { | ||
return JwtTokenResponse.builder() | ||
.accessToken(accessToken) | ||
.refreshToken(refreshToken) | ||
.build(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/justdo/plug/auth/global/jwt/kakao/preVersion/dto/KakaoAccount.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.justdo.plug.auth.global.jwt.kakao.preVersion.dto; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class KakaoAccount { | ||
private boolean profile_nickname_needs_agreement; | ||
private boolean profile_image_needs_agreement; | ||
private KakaoProfile profile; | ||
private boolean has_email; | ||
private boolean email_needs_agreement; | ||
private boolean is_email_valid; | ||
private boolean is_email_verified; | ||
private String email; | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/justdo/plug/auth/global/jwt/kakao/preVersion/dto/KakaoProfile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.justdo.plug.auth.global.jwt.kakao.preVersion.dto; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class KakaoProfile { | ||
private String nickname; | ||
private String thumbnail_image_url; | ||
private String profile_image_url; | ||
private boolean is_default_image; | ||
private boolean is_default_nickname; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/justdo/plug/auth/global/jwt/kakao/preVersion/dto/KakaoProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.justdo.plug.auth.global.jwt.kakao.preVersion.dto; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class KakaoProperties { | ||
private String nickname; | ||
private String profile_image; | ||
private String thumbnail_image; | ||
} |
13 changes: 13 additions & 0 deletions
13
...ava/com/justdo/plug/auth/global/jwt/kakao/preVersion/dto/response/KakaoTokenResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.justdo.plug.auth.global.jwt.kakao.preVersion.dto.response; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class KakaoTokenResponse { | ||
private String access_token; | ||
private String token_type; | ||
private String refresh_token; | ||
private Integer expires_in; | ||
private String scope; | ||
private Integer refresh_token_expires_in; | ||
} |
13 changes: 13 additions & 0 deletions
13
.../com/justdo/plug/auth/global/jwt/kakao/preVersion/dto/response/KakaoUserInfoResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.justdo.plug.auth.global.jwt.kakao.preVersion.dto.response; | ||
|
||
|
||
import com.justdo.plug.auth.global.jwt.kakao.preVersion.dto.KakaoAccount; | ||
import com.justdo.plug.auth.global.jwt.kakao.preVersion.dto.KakaoProperties; | ||
import lombok.Getter; | ||
@Getter | ||
public class KakaoUserInfoResponse { | ||
private Long id; | ||
private String connectedAt; | ||
private KakaoProperties properties; | ||
private KakaoAccount kakao_account; | ||
} |