flutter_naver_login icon indicating copy to clipboard operation
flutter_naver_login copied to clipboard

NaverAccessToken.isValid() 구현 버그

Open kghoon opened this issue 2 years ago • 0 comments

  bool isValid() {
    if (expiresAt.isEmpty || expiresAt == 'no token') return false;
    bool timeValid = Clock.now().isBefore(DateTime.parse(expiresAt));
    bool tokenExist = accessToken.isNotEmpty && accessToken != 'no token';
    return timeValid && tokenExist;
  }
  • expiresAt 은 string 형태의 unix timestamp 이고 seconds 단위입니다.
  • DateTime.parse는 위의 형식을 받아 들이지 않습니다 (https://api.flutter.dev/flutter/dart-core/DateTime/parse.html)
  • DateTime.fromMillisecondsSinceEpoch 를 사용하고, 숫자로 변환 후 * 1000 해서 값을 줘야 할 것 같습니다..
DateTime.fromMillisecondsSinceEpoch(int.parse(expiresAt) * 1000)

kghoon avatar Nov 21 '22 08:11 kghoon