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
Copy file name to clipboardExpand all lines: README.md
+80-15Lines changed: 80 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@
5
5
</p>
6
6
7
7
<palign="center">
8
-
<h4align="center">Build integrations that programmatically access your secrets in 1Password.</h4>
8
+
<h4align="center">Build integrations that programmatically interact with 1Password.</h4>
9
9
</p>
10
10
11
11
<palign="center">
@@ -26,7 +26,55 @@ If you're running a Linux distribution that still uses `libssl` version 1.1.1, s
26
26
27
27
## 🚀 Get started
28
28
29
-
To use the 1Password Python SDK in your project:
29
+
You can choose between two [authentication methods](https://developer.1password.com/docs/sdks/concepts#authentication) for the 1Password Python SDK: local authorization prompts from the [1Password desktop app](#option-1-1password-desktop-app) or automated authentication with a [1Password Service Account](#option-2-1password-service-account).
30
+
31
+
### Option 1: 1Password desktop app
32
+
33
+
[1Password desktop app authentication](https://developer.1password.com/docs/sdks/concepts#1password-desktop-app) is best for local integrations that require minimal setup from end users and sensitive workflows that require human-in-the-loop approval. To set up the SDK to authenticate with the 1Password app:
34
+
35
+
1. Install the [1Password desktop app](https://1password.com/downloads/) and sign in to your account in the app.
36
+
2. Select your account or collection at the top of the sidebar, then navigate to **Settings** > **Developer**.
37
+
3. Under Integrate with the 1Password SDKs, select **Integrate with other apps**.
38
+
4. If you want to authenticate with biometrics, navigate to **Settings** > **Security**, then turn on the option to unlock using [Touch ID](https://support.1password.com/touch-id-mac/), [Windows Hello](https://support.1password.com/windows-hello/), or [system authentication](https://support.1password.com/system-authentication-linux/).
39
+
5. Install the 1Password Python SDK in your project:
40
+
41
+
```bash
42
+
pip install onepassword-sdk
43
+
```
44
+
45
+
6. To use the Python SDK in your project, replace `your-account-name` in the code below with the name of your 1Password account as it appears at the top left sidebar of the 1Password desktop app.
46
+
47
+
```python
48
+
import asyncio
49
+
import os
50
+
from onepassword.client import Client, DesktopAuth
51
+
52
+
asyncdefmain():
53
+
# Connects to 1Password. Fill in your own integration name and version.
54
+
client =await Client.authenticate(
55
+
auth=DesktopAuth(
56
+
#TODO: Set to your 1Password account name.
57
+
account_name="your-account-name"
58
+
),
59
+
#TODO: Set to your own integration name and version.
60
+
integration_name="My 1Password Integration",
61
+
integration_version="v1.0.0",
62
+
)
63
+
64
+
# Retrieves a secret from 1Password. Takes a secret reference as input and returns the secret to which it points.
65
+
value =await client.secrets.resolve("op://vault/item/field")
66
+
# use value here
67
+
68
+
if__name__=='__main__':
69
+
asyncio.run(main())
70
+
71
+
```
72
+
73
+
Make sure to use [secret reference URIs](https://developer.1password.com/docs/cli/secret-reference-syntax/) with the syntax `op://vault/item/field` to securely load secrets from 1Password into your code.
74
+
75
+
### Option 2: 1Password Service Account
76
+
77
+
[Service account authentication](https://developer.1password.com/docs/sdks/concepts/#1password-service-account) is best for automated access and limiting your integration to least privilege access. To set up the SDK to authenticate with a service account token:
30
78
31
79
1.[Create a service account](https://my.1password.com/developer-tools/infrastructure-secrets/serviceaccount/?source=github-sdk) and give it the appropriate permissions in the vaults where the items you want to use with the SDK are saved.
32
80
2. Provision your service account token. We recommend provisioning your token from the environment. For example, to export your token to the `OP_SERVICE_ACCOUNT_TOKEN` environment variable:
@@ -80,7 +128,7 @@ Make sure to use [secret reference URIs](https://developer.1password.com/docs/cl
0 commit comments