|
1 | 1 | # Examples |
| 2 | +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: |
2 | 3 |
|
3 | | -This folder contains a code snippet that demonstrates how to use the 1Password Python SDK to retrieve a secret from 1Password and export it as an environment variable. |
| 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. |
4 | 12 |
|
5 | 13 | ## Prerequisites |
6 | 14 |
|
7 | 15 | 1. Clone the repository and follow the steps to [get started](https://github.com/1Password/onepassword-sdk-python/blob/main/README.md). |
8 | | -2. Make sure to export a valid service account token. For example: |
9 | | - ```bash |
10 | | - export OP_SERVICE_ACCOUNT_TOKEN="<your token>" |
11 | | - ``` |
12 | | -3. Make sure to export a valid vault uuid. For example: |
| 16 | +2. Ensure that you have a valid service account token by exporting it as an environment variable: |
| 17 | + ```bash |
| 18 | + export OP_SERVICE_ACCOUNT_TOKEN="<your token>" |
| 19 | + ``` |
| 20 | +3. Export the vault UUID you wish to interact with as an environment variable: |
13 | 21 | ```bash |
14 | 22 | export OP_VAULT_ID="<your vault uuid>" |
15 | 23 | ``` |
| 24 | + |
| 25 | +## Execution |
| 26 | + |
| 27 | +To run the example file, navigate to project root directory and run": |
| 28 | +```bash |
| 29 | +python example/example.py |
| 30 | +``` |
| 31 | +
|
| 32 | +## Terminal Output |
| 33 | +
|
| 34 | +When running the example, the terminal will display: |
| 35 | +
|
| 36 | +- A list of vaults and items. |
| 37 | +- Retrieved secrets and TOTP codes. |
| 38 | +- Details of newly created and updated items. |
| 39 | +- Generated passwords (PIN, memorable, random). |
| 40 | +- A shareable link for shared items. |
| 41 | +
|
| 42 | +These outputs show the results of vault and item operations, password generation, and sharing. |
0 commit comments