kakaoAuth static method
카카오 인증 에러 → KAuthError
Implementation
static KAuthError kakaoAuth(kakao.KakaoAuthException e) {
switch (e.error) {
case kakao.AuthErrorCause.accessDenied:
return KAuthError.fromCode(ErrorCodes.userCancelled, originalError: e);
case kakao.AuthErrorCause.invalidClient:
return KAuthError(
code: ErrorCodes.kakaoAppKeyInvalid,
message: '카카오 앱 키가 유효하지 않습니다.',
hint: 'Native App Key를 사용하세요. (REST API Key 아님)',
docs: 'https://developers.kakao.com/console',
originalError: e,
);
case kakao.AuthErrorCause.invalidGrant:
return KAuthError(
code: ErrorCodes.tokenExpired,
message: '인증 정보가 만료되었습니다.',
hint: '다시 로그인해주세요.',
originalError: e,
);
case kakao.AuthErrorCause.invalidRequest:
return KAuthError(
code: ErrorCodes.kakaoInvalidRedirectUri,
message: '잘못된 요청입니다.',
hint: '플랫폼 설정(번들 ID, 패키지명)을 확인하세요.',
docs: 'https://developers.kakao.com/console',
originalError: e,
);
case kakao.AuthErrorCause.invalidScope:
return KAuthError(
code: ErrorCodes.kakaoConsentRequired,
message: '요청한 권한이 유효하지 않습니다.',
hint: '동의항목에서 해당 권한을 활성화하세요.',
docs: 'https://developers.kakao.com/console',
originalError: e,
);
case kakao.AuthErrorCause.serverError:
return KAuthError(
code: ErrorCodes.networkError,
message: '카카오 서버 오류가 발생했습니다.',
hint: '잠시 후 다시 시도해주세요.',
originalError: e,
);
case kakao.AuthErrorCause.unauthorized:
return KAuthError(
code: ErrorCodes.kakaoAppKeyInvalid,
message: '카카오 로그인 권한이 없습니다.',
hint: '개발자센터에서 카카오 로그인을 활성화하세요.',
docs: 'https://developers.kakao.com/console',
originalError: e,
);
default:
return KAuthError(
code: ErrorCodes.loginFailed,
message: '카카오 로그인 중 오류가 발생했습니다.',
hint: e.message ?? '다시 시도해주세요.',
originalError: e,
);
}
}