freedesktop_secret 0.0.1-dev.3 copy "freedesktop_secret: ^0.0.1-dev.3" to clipboard
freedesktop_secret: ^0.0.1-dev.3 copied to clipboard

Dart client for the FreeDesktop Secret Service API (org.freedesktop.secrets) for storing secrets on Linux.

example/main.dart

// ignore_for_file: avoid_print

import 'package:freedesktop_secret/freedesktop_secret.dart';

void main() async {
  final client = FreeDesktopSecret();

  await client.initialize();

  try {
    final lookupAttributes = {'key': 'refresh_token', 'userId': '1'};

    await client.storeSecretText(
      attributes: lookupAttributes,
      secret: '123',
      label: 'User Refresh Token',
      replace: true,
    );

    print('Stored the secret');

    final secret = await client.lookupSecret(
      attributes: lookupAttributes,
      duplicateStrategy: .first,
    );

    print('Lookup secret: ${secret?.secretAsText()}');

    final deleteResult = await client.deleteSecret(
      attributes: lookupAttributes,
    );

    if (deleteResult == 1) {
      print('Deleted the secret');
    } else if (deleteResult > 1) {
      print('Deleted $deleteResult secrets');
    }
  } finally {
    await client.close();
  }
}
2
likes
0
points
611
downloads

Publisher

verified publisherechoellet.dev

Weekly Downloads

Dart client for the FreeDesktop Secret Service API (org.freedesktop.secrets) for storing secrets on Linux.

Repository (GitHub)
View/report issues

Topics

#os-integration #freedesktop #dbus

License

unknown (license)

Dependencies

dbus

More

Packages that depend on freedesktop_secret