setRefreshToken method

Future<void> setRefreshToken(
  1. String refreshToken
)

Implementation

Future<void> setRefreshToken(String refreshToken) async {
  /// refresh token设置前,先清掉 access token
  await cache.removeStore(cache.accessTokenKey);
  await cache.removeStore(cache.accessTokenExpireKey);
  await cache.setStore(cache.refreshTokenKey, refreshToken);

  /// refresh token 30天后过期
  await cache.setStore(cache.refreshTokenExpireKey,
      DateTime.now().add(Duration(days: 30)).millisecondsSinceEpoch);
}