강의

멘토링

로드맵

Inflearn Community Q&A

ubiocean's profile image
ubiocean

asked

[Code Factory] [Intermediate] Flutter Real Practice! State Management, Cache Management, Code Generation, GoRouter, Authentication Logic, etc. Essential Skills to Become an Intermediate!

Finishing Authentication

[GoRouter & Authentication 마무리하기] 401 에러

Resolved

Written on

·

912

4

토큰 만료 이후 GoRouter & Authentication 따라할 경우 401 에러를 저도 만났어요. 유사 질문들과 답변이 있어, 저도 경험기 공유합니다.

증상

원인

  • refreshToken 이 있거나 accessToken이 있는 경우에 토큰이 만료된 상태이면 증상 발생 의심

해결

  • user_me_provider.dart 파일 > getMe() 에서

  • try catch & state 초기화 추가

  • 재실행

Future<void> getMe() async {
  // ... 중략

  try {
    final resp = await repository.getMe();

    state = resp;
  } catch(e, stack) {
    print(e);
    print(stack);

    state = null;
  }
}

저와 동일한 오류를 만나는 분에게 소소한 도움이 되길 바래요 :)

flutter401gorouterauthentication

Quiz

액세스/리프레시 토큰 만료로 인해 401 또는 403 에러 발생 시 가장 먼저 취할 수 있는 일반적인 대처 방법은 무엇일까요?

서버에 토큰 재발급 요청

토큰 관련 데이터를 모두 삭제하고 사용자 로그아웃 처리

에러 메시지를 사용자에게 표시하고 앱 종료

네트워크 연결 상태 확인 후 재시도

Answer 2

0

센스 굿! 깔끔한 정리 감사해요. 현시점 플로우대로 강의 수강시 나오는 현상이네요~!

0

codefactory님의 프로필 이미지
codefactory
Instructor

안녕하세요!

정보 감사합니다!

ubiocean's profile image
ubiocean

asked

Ask a question