Skip to content

fix: RefreshError시 로그인 요청 응답 추가#22

Merged
Kimgyuilli merged 3 commits into
mainfrom
fix/error-38bd956-20260407082503
Apr 7, 2026
Merged

fix: RefreshError시 로그인 요청 응답 추가#22
Kimgyuilli merged 3 commits into
mainfrom
fix/error-38bd956-20260407082503

Conversation

@Kimgyuilli

Copy link
Copy Markdown
Owner

자동 생성된 에러 수정 PR

에러 정보

항목 내용
타입 RefreshError
메시지 ('invalid_grant: Token has been expired or revoked.', {'error': 'invalid_grant', 'error_description': 'Token has been expired or revoked.'})
요청 GET /api/calendar/calendars
발생 시간 2026-04-07T08:24:58.663815+00:00

근본 원인

사용자의 Google 인증 정보에서 refresh token이 더 이상 유효하지 않거나 만료된 상태입니다. 이로 인해 새 토큰을 가져올 수 없는 문제가 발생했습니다.

AI 분석

에러 메시지는 주로 Google OAuth 2.0 인증 과정에서 발생합니다. 이는 액세스 토큰이 만료됐거나 취소되었을 때 발생할 수 있습니다. 문제는 'get_google_user' 함수에서 credentials.expired 상태일 때 토큰 갱신을 시도하지만, 이 과정에서 문제가 발생하면서 RefreshError가 발생합니다.

수정 내용

Google OAuth 2.0의 RefreshError 발생 시, 사용자에게 새로 로그인하도록 안내 메시지를 반환하십시오. 이를 위해 'get_google_user' 함수에서 RefreshError를 처리하여 적절한 HTTP 응답을 제공합니다.

수정된 파일

  • backend/app/auth/dependencies.py
  • backend/app/auth/dependencies.py

변경 diff

backend/app/auth/dependencies.py

--- a/backend/app/auth/dependencies.py
+++ b/backend/app/auth/dependencies.py
@@ -40,13 +40,13 @@
             await asyncio.to_thread(credentials.refresh, Request())
             user.google_oauth_token = encrypt_value(credentials.token)
             await db.commit()
-        except Exception as exc:
+        except google.auth.exceptions.RefreshError as exc:
             logger.warning(f"Google 토큰 갱신 실패 (user={user.id}): {exc}")
             raise HTTPException(
                 status_code=401,
                 detail={
                     "code": "token_expired",
-                    "message": "Google 토큰이 만료되었습니다. 다시 로그인해주세요.",
+                    "message": "Google 인증 정보가 만료되었거나 취소되었습니다. 다시 로그인해야 합니다.",
                 },
             ) from exc
 

이 PR은 Error Bot이 자동으로 생성했습니다.
반드시 코드 리뷰 후 머지하세요.

@Kimgyuilli Kimgyuilli merged commit 905c0a2 into main Apr 7, 2026
5 checks passed
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