generateApiKey method

ApiKey generateApiKey({
  1. DateTime? expiresAt,
})

Generates a new API key, optionally with an expiration date, and adds it to the set of managed API keys.

  • Parameters:

    • expiresAt: The optional expiration date of the API key.
  • Returns: The newly generated API key.

Implementation

ApiKey generateApiKey({DateTime? expiresAt}) {
  final key = _uuid.v4();
  final apiKey =
      ApiKey(key: key, createdAt: DateTime.now(), expiresAt: expiresAt);
  _apiKeys.add(apiKey);
  return apiKey;
}