Skip to content

feat: 카카오토큰, 날씨 api 수정#152

Merged
sungahbak merged 2 commits intodevelopfrom
feature/debug-api
Mar 26, 2026
Merged

feat: 카카오토큰, 날씨 api 수정#152
sungahbak merged 2 commits intodevelopfrom
feature/debug-api

Conversation

@sungahbak
Copy link
Copy Markdown
Contributor

  • [FEAT]

PR템플릿

변경 사항 요약

  • 변경사항 요약본 작성

체크리스트

  • 코드 빌드 성공
  • 에뮬레이터 실행 시 성공

사진올리는곳

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on improving token handling, updating the base URL for API requests, and integrating a weather API. The changes enhance the app's reliability and introduce new features related to weather data.

Highlights

  • 카카오 토큰 처리 개선: SplashActivity에서 카카오 토큰을 확인하는 로직을 수정하여, AuthDataStore에 저장된 액세스 토큰을 직접 확인하도록 변경했습니다. 이를 통해 토큰 관리의 효율성을 높였습니다.
  • API Base URL 변경: RetrofitClient의 BASE_URL을 'http://ec2-3-35-233-51.ap-northeast-2.compute.amazonaws.com:8080/'에서 'https://pace-server.kro.kr/'로 변경했습니다. 이는 서버 환경 변화에 따른 업데이트입니다.
  • 날씨 API 연동: 날씨 정보를 가져오기 위해 WeatherRepository, WeatherService, NetworkModule을 추가하고 설정했습니다. Retrofit을 사용하여 OpenWeatherMap API와 통신합니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이번 PR은 카카오 토큰 관리 방식 변경과 날씨 API 연동 추가에 대한 내용을 담고 있습니다. 전반적으로 Hilt를 적용하여 의존성 주입을 개선하고, 기존 로직을 정리하는 좋은 방향의 수정입니다. 다만, 몇 가지 개선점을 제안합니다. 새로 추가된 날씨 API 관련 코드의 아키텍처 개선, API URL 관리 방식, 그리고 스플래시 화면에서의 토큰 유효성 검사 로직 보강이 필요해 보입니다. 자세한 내용은 각 파일에 남긴 코멘트를 참고해주세요.

class WeatherRepository @Inject constructor(
private val weatherService: WeatherService
) {
fun fetchWeather(cityName: String, apiKey: String) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

API 키를 매개변수로 전달하는 것은 보안상 위험할 수 있습니다. 키가 ViewModel이나 UI 레이어에 노출될 수 있기 때문입니다. API 키는 BuildConfig나 암호화된 SharedPreferences와 같은 안전한 곳에 저장하고, 데이터 레이어 내에서 직접 참조하는 것이 좋습니다. 함수 시그니처에서 apiKey를 제거하는 것을 고려해 보세요.

Comment on lines +44 to +46
if (accessToken != null) {
// 1. 토큰이 있으면 로그인된 상태 -> 메인으로
navigateToMain()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

현재 로직은 액세스 토큰의 존재 여부만 확인하고 유효성은 검사하지 않습니다. 만약 토큰이 만료되었다면, 사용자는 메인 화면으로 이동하더라도 API 호출이 계속 실패하여 앱이 비정상적으로 동작하는 것처럼 보일 수 있습니다. 스플래시 화면에서 간단한 API(예: 사용자 정보 가져오기)를 호출하여 토큰의 유효성을 검증하거나, 또는 모든 API 요청에 대해 401 에러를 공통으로 처리하여 토큰 만료 시 자동으로 로그인 화면으로 보내는 로직(예: OkHttp의 Authenticator)을 구현하는 것을 고려해보세요.

Comment on lines +11 to +32
fun fetchWeather(cityName: String, apiKey: String) {
weatherService.getWeather(cityName, apiKey).enqueue(object : retrofit2.Callback<WeatherResponse> {
override fun onResponse(call: retrofit2.Call<WeatherResponse>, response: retrofit2.Response<WeatherResponse>) {

Log.d("PACE_DEBUG", "Status Code: ${response.code()}")
Log.d("PACE_DEBUG", "Requested URL: ${call.request().url}")

if (response.isSuccessful) {
val weatherData = response.body()
Log.d("PACE_DEBUG", "날씨 데이터 수신 성공: $weatherData")
} else {

Log.e("PACE_DEBUG", "에러 발생: ${response.errorBody()?.string()}")
}
}

override fun onFailure(call: retrofit2.Call<WeatherResponse>, t: Throwable) {

Log.e("PACE_DEBUG", "통신 실패 원인: ${t.message}")
}
})
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

현재 fetchWeather 함수는 콜백을 사용하며 결과를 로그로만 남기고 있습니다. 이 방식은 ViewModel 등에서 데이터를 활용하기 어렵게 만들고 테스트도 복잡하게 합니다. 코루틴을 사용하는 현대적인 안드로이드 개발 방식에 맞춰 suspend 함수로 리팩토링하는 것을 강력히 권장합니다. 이렇게 하면 비동기 코드를 더 간결하고 읽기 쉽게 만들 수 있습니다.

    suspend fun fetchWeather(cityName: String, apiKey: String): WeatherResponse = suspendCancellableCoroutine { continuation ->
        val call = weatherService.getWeather(cityName, apiKey)
        call.enqueue(object : retrofit2.Callback<WeatherResponse> {
            override fun onResponse(call: retrofit2.Call<WeatherResponse>, response: retrofit2.Response<WeatherResponse>) {
                if (response.isSuccessful) {
                    response.body()?.let { data ->
                        continuation.resume(data)
                    } ?: continuation.resumeWithException(IllegalStateException("Weather data is null"))
                } else {
                    continuation.resumeWithException(Exception("API Error: ${response.code()} ${response.message()}"))
                }
            }

            override fun onFailure(call: retrofit2.Call<WeatherResponse>, t: Throwable) {
                if (continuation.isCancelled) return
                continuation.resumeWithException(t)
            }
        })

        continuation.invokeOnCancellation {
            call.cancel()
        }
    }

fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit {
return Retrofit.Builder()
.baseUrl("http://ec2-3-35-233-51.ap-northeast-2.compute.amazonaws.com:8080/")
.baseUrl("https://pace-server.kro.kr/")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

이곳과 72라인에 있는 기본 URL들이 하드코딩되어 있으며, app/src/main/java/com/example/pace/data/api/RetrofitClient.kt 파일에도 중복으로 정의되어 있습니다. URL을 여러 곳에 하드코딩하면 향후 유지보수가 어려워질 수 있습니다. 이 URL들을 한 곳(예: 이 파일 상단의 companion object 또는 별도의 상수 파일)에 상수로 정의하고 재사용하는 것을 권장합니다.

@Inject
lateinit var authDataStore: AuthDataStore

//private val authDataStore by lazy { (application as PaceApplication).authDataStore }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

이 주석 처리된 코드는 더 이상 사용되지 않으므로 삭제하는 것이 좋습니다. 코드를 깨끗하게 유지하는 데 도움이 됩니다.

@sungahbak sungahbak merged commit 3021572 into develop Mar 26, 2026
@sungahbak sungahbak deleted the feature/debug-api branch April 6, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant