thedavecarroll / OnePassword.NET

1Password CLI Wrapper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OnePassword.NET - 1Password CLI Wrapper

This library serves as a .NET wrapper for the 1Password command-line tool op.exe ( Download | Documentation ).

nuget master develop

References

This library targets .NET 6.0 and .NET 7.0.

Dependencies

This library has no dependencies.

Quick Start

Creating an instance of the manager

var onePassword = new OnePasswordManager();

Adding your account and signing in for the first time

var domain = "my.1password.com";
var email = "your@email.com";
var secretKey = "A3-YOUR-SECRET-KEY";
var password = "yourpassword";

onePassword.AddAccount(domain, email, secretKey, password);
onePassword.SignIn(password);

Signing in for subsequent connections

onePassword.UseAccount(domain);
onePassword.SignIn(password);

Getting all vaults

var vaults = onePassword.GetVaults();

Selecting a specific vault

var vault = vaults.First(x => x.Name == "Private");

Creating an item using a template

var serverTemplate = onePassword.GetTemplate(Category.Server);

serverTemplate.Title = "Your Item's Title";
serverTemplate.Fields.First(x => x.Label == "username").Value = "secretuser";
serverTemplate.Fields.First(x => x.Label == "password").Value = "secretpass";

var serverItem = onePassword.CreateItem(serverTemplate, vault);

Note: If you want to reuse the same template for several items, make sure you clone the instance to avoid reference issues.

var server1 = serverTemplate.Clone();
var server2 = serverTemplate.Clone();

Getting all items in a vault

var items = onePassword.GetItems(vault);

Selecting a specific item

var item = items.First(x => x.Title == "Your Item's Title");

Editing a specific item

item.Fields.First(x => x.Label == "password").Value = "newpass";
onePassword.EditItem(item, vault);

Archiving an item

onePassword.ArchiveItem(item, vault);

Deleting an item

onePassword.DeleteItem(item, vault);

Signing out

onePassword.SignOut();

About

1Password CLI Wrapper

License:MIT License


Languages

Language:C# 100.0%