Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize example documentation across repos #16

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Examples

This folder contains a code snippet that demonstrates how to use the 1Password Python SDK to retrieve a secret from 1Password.

## Prerequisites

1. Clone the repository and follow the steps to [get started](https://github.com/1Password/onepassword-sdk-python?tab=readme-ov-file#get-started).
2. Make sure to export a valid service account token. For example:
```bash
export OP_SERVICE_ACCOUNT_TOKEN="<your token>"
```
5 changes: 3 additions & 2 deletions example/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ async def main():
# Gets your service account token from the OP_SERVICE_ACCOUNT_TOKEN environment variable.
token = os.getenv("OP_SERVICE_ACCOUNT_TOKEN")

# Connects to 1Password.
# Authenticates with your token and connects to 1Password.
client = await Client.authenticate(auth=token, integration_name="My 1Password Integration", integration_version="v1.0.0")

# Retrieves a secret from 1Password. Takes a secret reference as input and returns the secret to which it points.
# Retrieves a secret from 1Password.
# Takes a secret reference as input and returns the secret to which it points.
libutcher marked this conversation as resolved.
Show resolved Hide resolved
value = await client.secrets.resolve("op://vault/item/field")
print(value)

Expand Down
Loading