-
Notifications
You must be signed in to change notification settings - Fork 0
[FIX] 카카오톡 미로그인 시 소셜로그인 안되는 현상 수정 #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ import com.kakao.sdk.auth.model.OAuthToken | |||||||||||||||||||||||||
| import com.kakao.sdk.common.model.ApiError | ||||||||||||||||||||||||||
| import com.kakao.sdk.common.model.AuthError | ||||||||||||||||||||||||||
| import com.kakao.sdk.common.model.ClientError | ||||||||||||||||||||||||||
| import com.kakao.sdk.common.model.ClientErrorCause | ||||||||||||||||||||||||||
| import com.kakao.sdk.common.model.KakaoSdkError | ||||||||||||||||||||||||||
| import com.kakao.sdk.user.UserApiClient | ||||||||||||||||||||||||||
| import kotlinx.coroutines.CancellableContinuation | ||||||||||||||||||||||||||
|
|
@@ -28,22 +29,20 @@ class KakaoLoginManager( | |||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||
| unlinkKakao() | ||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||
| val accessToken = | ||||||||||||||||||||||||||
| if (UserApiClient.instance.isKakaoTalkLoginAvailable(context)) { | ||||||||||||||||||||||||||
| loginWithKakaoTalk() | ||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||
| loginWithKakaoAccount() | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| val accessToken = fetchAccessToken() | ||||||||||||||||||||||||||
| onSuccess(accessToken) | ||||||||||||||||||||||||||
| } catch (error: ClientError) { | ||||||||||||||||||||||||||
| if (error.reason == ClientErrorCause.Cancelled) { | ||||||||||||||||||||||||||
| onFailure(Exception(context.getString(R.string.login_user_cancelled))) | ||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||
| onFailure(Exception(context.getString(R.string.login_client_error))) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } catch (error: AuthError) { | ||||||||||||||||||||||||||
| // OAuth 인증 과정 에러 | ||||||||||||||||||||||||||
| onFailure(Exception(context.getString(R.string.login_auth_error))) | ||||||||||||||||||||||||||
| } catch (error: ApiError) { | ||||||||||||||||||||||||||
| // API 호출 에러 | ||||||||||||||||||||||||||
| onFailure(Exception(context.getString(R.string.login_api_error))) | ||||||||||||||||||||||||||
| } catch (error: ClientError) { | ||||||||||||||||||||||||||
| // SDK 내부 에러 | ||||||||||||||||||||||||||
| onFailure(Exception(context.getString(R.string.login_client_error))) | ||||||||||||||||||||||||||
| } catch (error: KakaoSdkError) { | ||||||||||||||||||||||||||
| // 카카오 SDK 에러 | ||||||||||||||||||||||||||
| onFailure(Exception(context.getString(R.string.login_sdk_error))) | ||||||||||||||||||||||||||
|
|
@@ -84,28 +83,35 @@ class KakaoLoginManager( | |||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| private suspend fun fetchAccessToken(): String { | ||||||||||||||||||||||||||
| if (UserApiClient.instance.isKakaoTalkLoginAvailable(context).not()) { | ||||||||||||||||||||||||||
| return loginWithKakaoAccount() | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| return runCatching { loginWithKakaoTalk() } | ||||||||||||||||||||||||||
| .getOrElse { | ||||||||||||||||||||||||||
| // 카카오톡 로그인 단계에서 실패하면 즉시 웹 계정 로그인으로 폴백 | ||||||||||||||||||||||||||
| loginWithKakaoAccount() | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // 카카오 로그인 결과 처리 | ||||||||||||||||||||||||||
| private fun handleLoginResult( | ||||||||||||||||||||||||||
| token: OAuthToken?, | ||||||||||||||||||||||||||
| error: Throwable?, | ||||||||||||||||||||||||||
| continuation: CancellableContinuation<String>, | ||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||
| when { | ||||||||||||||||||||||||||
| error != null -> { | ||||||||||||||||||||||||||
| token != null -> continuation.resume(token.accessToken) | ||||||||||||||||||||||||||
| error != null -> | ||||||||||||||||||||||||||
| continuation.resumeWith( | ||||||||||||||||||||||||||
| Result.failure( | ||||||||||||||||||||||||||
| Exception(context.getString(R.string.login_user_cancelled)), | ||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||
| Result.failure(error), | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| token != null -> continuation.resume(token.accessToken) | ||||||||||||||||||||||||||
| else -> { | ||||||||||||||||||||||||||
| else -> | ||||||||||||||||||||||||||
| continuation.resumeWith( | ||||||||||||||||||||||||||
| Result.failure( | ||||||||||||||||||||||||||
| Exception(context.getString(R.string.login_user_cancelled)), | ||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
|
Comment on lines
+109
to
114
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
이러한 예기치 않은 상태는
Suggested change
|
||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.