refreshAccessToken method

  1. @override
Future<void> refreshAccessToken()
override

刷新 accessToken

Implementation

@override
Future<void> refreshAccessToken() async {
  /// 可能会同时调用多次刷新access token,这里把它们合并成一个
  if (AuthProvider._refreshAccessTokenFuture == null) {
    /// 没有正在刷新,那么正常执行刷新逻辑
    AuthProvider._refreshAccessTokenFuture = this._refreshAccessToken();
  }

  try {
    await AuthProvider._refreshAccessTokenFuture;
  } catch (e) {
    throw e;
  } finally {
    AuthProvider._refreshAccessTokenFuture = null;
  }
}