You can choose between two authentication methods for the 1Password Go SDK: local authorization prompts from the 1Password desktop app or automated authentication with a 1Password Service Account.
This project is licensed under MIT. Use of the 1Password APIs and services accessed through these tools is governed by the 1Password API Terms of Service.
1Password desktop app authentication 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:
Install the 1Password desktop app and sign in to your account in the app.
Select your account or collection at the top of the sidebar, then navigate to Settings > Developer.
Under Integrate with the 1Password SDKs, select Integrate with other apps.
If you want to authenticate with biometrics, navigate to Settings > Security, then turn on the option to unlock using Touch ID, Windows Hello, or system authentication.
Install the 1Password Go SDK in your project:
go get github.com/1password/onepassword-sdk-go
To use the Go 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.
package main
import (
"context"
"os"
"github.com/1password/onepassword-sdk-go"
)
func main() {
client, err := onepassword.NewClient(
context.TODO(),
onepassword.WithDesktopAppIntegration("your-account-name"),
// TODO: Set the following to your own integration name and version.
onepassword.WithIntegrationInfo("My 1Password Integration", "v1.0.0"),
)
if err != nil {
// handle err
}
secret, err := client.Secrets().Resolve(context.TODO(), "op://vault/item/field")
if err != nil {
// handle err
}
// do something with the secret
}
Make sure to use secret reference URIs with the syntax op://vault/item/field to securely load secrets from 1Password into your code.
Service account authentication 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:
Create a service account and give it the appropriate permissions in the vaults where the items you want to use with the SDK are saved.
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:
macOS or Linux
export OP_SERVICE_ACCOUNT_TOKEN=<your-service-account-token>
Windows
$Env:OP_SERVICE_ACCOUNT_TOKEN = "<your-service-account-token>"
Install the 1Password Go SDK in your project:
go get github.com/1password/onepassword-sdk-go
Use the Go SDK in your project:
package main
import (
"context"
"os"
"github.com/1password/onepassword-sdk-go"
)
func main() {
token := os.Getenv("OP_SERVICE_ACCOUNT_TOKEN")
client, err := onepassword.NewClient(
context.TODO(),
onepassword.WithServiceAccountToken(token),
// TODO: Set the following to your own integration name and version.
onepassword.WithIntegrationInfo("My 1Password Integration", "v1.0.0"),
)
if err != nil {
// handle err
}
secret, err := client.Secrets().Resolve(context.TODO(), "op://vault/item/field")
if err != nil {
// handle err
}
// do something with the secret
}
Make sure to use secret reference URIs with the syntax op://vault/item/field to securely load secrets from 1Password into your code.
1Password SDKs are in active development. We're keen to hear what you'd like to see next. Let us know by upvoting or filing an issue.
Operations:
Field types:
If you want to cross compile the Go SDK while using the 1Password desktop app to authenticate, you'll need to enable CGO.
CGO can be enabled either by default if your system permits that, or deliberately if your system doesn't permit that by:
CGO_ENABLED env var to 1.260 followers · starred Jun 2026
18 followers · starred Oct 2024
You can choose between two authentication methods for the 1Password Go SDK: local authorization prompts from the 1Password desktop app or automated authentication with a 1Password Service Account.
This project is licensed under MIT. Use of the 1Password APIs and services accessed through these tools is governed by the 1Password API Terms of Service.
1Password desktop app authentication 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:
Install the 1Password desktop app and sign in to your account in the app.
Select your account or collection at the top of the sidebar, then navigate to Settings > Developer.
Under Integrate with the 1Password SDKs, select Integrate with other apps.
If you want to authenticate with biometrics, navigate to Settings > Security, then turn on the option to unlock using Touch ID, Windows Hello, or system authentication.
Install the 1Password Go SDK in your project:
go get github.com/1password/onepassword-sdk-go
To use the Go 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.
package main
import (
"context"
"os"
"github.com/1password/onepassword-sdk-go"
)
func main() {
client, err := onepassword.NewClient(
context.TODO(),
onepassword.WithDesktopAppIntegration("your-account-name"),
// TODO: Set the following to your own integration name and version.
onepassword.WithIntegrationInfo("My 1Password Integration", "v1.0.0"),
)
if err != nil {
// handle err
}
secret, err := client.Secrets().Resolve(context.TODO(), "op://vault/item/field")
if err != nil {
// handle err
}
// do something with the secret
}
Make sure to use secret reference URIs with the syntax op://vault/item/field to securely load secrets from 1Password into your code.
Service account authentication 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:
Create a service account and give it the appropriate permissions in the vaults where the items you want to use with the SDK are saved.
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:
macOS or Linux
export OP_SERVICE_ACCOUNT_TOKEN=<your-service-account-token>
Windows
$Env:OP_SERVICE_ACCOUNT_TOKEN = "<your-service-account-token>"
Install the 1Password Go SDK in your project:
go get github.com/1password/onepassword-sdk-go
Use the Go SDK in your project:
package main
import (
"context"
"os"
"github.com/1password/onepassword-sdk-go"
)
func main() {
token := os.Getenv("OP_SERVICE_ACCOUNT_TOKEN")
client, err := onepassword.NewClient(
context.TODO(),
onepassword.WithServiceAccountToken(token),
// TODO: Set the following to your own integration name and version.
onepassword.WithIntegrationInfo("My 1Password Integration", "v1.0.0"),
)
if err != nil {
// handle err
}
secret, err := client.Secrets().Resolve(context.TODO(), "op://vault/item/field")
if err != nil {
// handle err
}
// do something with the secret
}
Make sure to use secret reference URIs with the syntax op://vault/item/field to securely load secrets from 1Password into your code.
1Password SDKs are in active development. We're keen to hear what you'd like to see next. Let us know by upvoting or filing an issue.
Operations:
Field types:
If you want to cross compile the Go SDK while using the 1Password desktop app to authenticate, you'll need to enable CGO.
CGO can be enabled either by default if your system permits that, or deliberately if your system doesn't permit that by:
CGO_ENABLED env var to 1.260 followers · starred Jun 2026
18 followers · starred Oct 2024