KSM SDKを使用した汎用.Netスクリプト

// Keeper.SecretsManagerパッケージに応じて
// 「dotnet add package Keeper.SecretsManager」を実行します
using SecretsManager;

while (Console.ReadLine() is string line)
{
    Console.WriteLine(line);
    var base64EncodedBytes = System.Convert.FromBase64String(line);
    var json = System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
    var jsonDom = System.Text.Json.JsonSerializer.Deserialize<System.Text.Json.Nodes.JsonObject>(json)!;

    var providerRecordUid = (string)jsonDom["providerRecordUid"]!;
    var resourceRecordUid = (string)jsonDom["resourceRecordUid"]!;
    var userRecordUid = (string)jsonDom["userRecordUid"]!;
    var newPassword = (string)jsonDom["newPassword"]!;
    var oldPassword = (string)jsonDom["oldPassword"]!;
    var user = (string)jsonDom["user"]!;
    Console.WriteLine($"providerRecordUid={providerRecordUid}\n" +
        $"resourceRecordUid={resourceRecordUid}\n" +
        $"userRecordUid={userRecordUid}\n" +
        $"newPassword={newPassword}\n" +
        $"oldPassword={oldPassword}\n" +
        $"user={user}\n");

    //var storage = new LocalConfigStorage("config.json");
    var storage = new InMemoryStorage("BASE64Config==");
    var options = new SecretsManagerOptions(storage);
    var recordUids = new string[] { providerRecordUid, resourceRecordUid, userRecordUid };
    var secrets = await SecretsManagerClient.GetSecrets(options, recordUids);
    foreach (var record in secrets.Records)
    {
        Console.WriteLine($"Record UID: {record.RecordUid}, Title: {record.Data.title}");
    }
}

最終更新