confirmToken method

Future<void> confirmToken()

Implementation

Future<void> confirmToken() async {
  if (tokenGenerator == null) {
    throw AuthorizationException(
      'Token generator not configured. '
      'Call withApiKey(), withJwt(), or withGenerator() first.',
    );
  } else {
    if (tokenExpiry.isBefore(DateTime.now())) {
      final tokenData = await tokenGenerator!.generate();

      _token = tokenData.accessToken;

      tokenExpiry.add(Duration(seconds: tokenData.expiresIn));
    }
  }
}