hasTokenExpired static method

bool hasTokenExpired(
  1. String token, [
  2. DateTime? compareAgainst
])

Implementation

static bool hasTokenExpired(String token, [DateTime? compareAgainst]) {
  try {
    Map<String, dynamic> parsed = _decodeToken(token);
    num exp = parsed["exp"] * 1000;
    DateTime expiresIn = DateTime.fromMillisecondsSinceEpoch(
      exp.toInt(),
    );
    return expiresIn.isBefore(compareAgainst ?? DateTime.now());
  } catch (e, s) {
    debugPrint("$e\n$s");
    return true;
  }
}