onToken static method

bool onToken(
  1. TokenResponse response
)

Call this when you get your token. Will return false if the token was null, true otherwise

Implementation

static bool onToken(TokenResponse response) {
  if (response.accessToken != null) {
    _logger.info("Got a token!");
    tokenResponse = response;
    token = response.accessToken!;
    refreshToken = response.refreshToken!;

    if (response.accessTokenExpirationDateTime != null) {
      refreshesAt = response.accessTokenExpirationDateTime;
    }

    List<String> parts = token!.split('.');
    String payload = parts[1];
    String decoded = B64urlEncRfc7515.decodeUtf8(payload);
    tokenData = json.decode(decoded);
    return true;
  } else {
    _logger.error("Token was null!");
    return false;
  }
}