You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This folder contains a code snippet demonstrating how to use the 1Password Python SDK for performing various operations on 1Password vaults and items. Specifically, the example showcases how to:
3
+
4
+
- Authenticate with the 1Password API using a service account token.
5
+
- List available vaults and items within those vaults.
6
+
- Retrieve a specific secret and resolve a one-time password (TOTP).
7
+
- Create a new item in a vault with multiple fields and tags.
8
+
- Update an existing item by modifying its fields and adding a new website.
9
+
- Generate different types of passwords (PIN, memorable, and random).
10
+
- Share an item with valid recipients and create a shareable link.
11
+
- Archive or delete items from the vault.
12
+
- Create and manage SSH key items.
13
+
- Create and manage document items, including replacing and reading documents.
14
+
- Create and manage file field items by attaching and deleting files.
15
+
16
+
## Prerequisites
17
+
18
+
1. Clone the repository and follow the steps to [get started](https://github.com/1Password/onepassword-sdk-python/blob/main/README.md).
19
+
2. Ensure that you have a valid service account token by exporting it as an environment variable:
20
+
```bash
21
+
export OP_SERVICE_ACCOUNT_TOKEN="<your token>"
22
+
```
23
+
3. Export the vault UUID you wish to interact with as an environment variable:
24
+
```bash
25
+
export OP_VAULT_ID="<your vault uuid>"
26
+
```
27
+
28
+
## How to Run
29
+
30
+
To run the example file, navigate to project root directory and run:
31
+
```bash
32
+
python example/example.py
33
+
```
34
+
35
+
## Terminal Output
36
+
37
+
When running the example, the terminal will display:
38
+
39
+
- A list of vaults and items.
40
+
- Retrieved secrets and TOTP codes.
41
+
- Details of newly created and updated items.
42
+
- Generated passwords (PIN, memorable, random).
43
+
- A shareable link for shared items.
44
+
- SSH key attributes like public key and fingerprint.
45
+
- Document content after replacing the file.
46
+
- A list of file field items and file deletions.
47
+
48
+
These outputs show the results of vault and item operations, password generation, item sharing, and management of SSH and document items.
0 commit comments