refreshAccessToken method

  1. @override
Future<void> refreshAccessToken()

Implementation

@override
Future<void> refreshAccessToken() async {
  final refreshToken = _refreshToken;
  if (refreshToken == null) {
    await _clearSession(SessionStateChangeReason.noToken);
    return;
  }

  final xDeviceInfo = await _getXDeviceInfo();
  final tokenRequest = OIDCTokenRequest(
    grantType: GrantType.refreshToken,
    clientID: clientID,
    refreshToken: refreshToken,
    xDeviceInfo: xDeviceInfo,
  );
  try {
    final tokenResponse = await _apiClient.sendTokenRequest(tokenRequest);
    await _persistTokenResponse(
        tokenResponse, SessionStateChangeReason.foundToken);
  } catch (e) {
    await _handleInvalidGrantException(e);
    if (e is OAuthException && e.error == "invalid_grant") {
      return;
    }
    rethrow;
  }
}