Skip to content

Latest commit

 

History

History
85 lines (63 loc) · 2.83 KB

README.md

File metadata and controls

85 lines (63 loc) · 2.83 KB

1Password Connect SDK for Go

Access your 1Password items in your Go applications through your self-hosted 1Password Connect server.

Get started

The 1Password Connect Go SDK provides access to the 1Password Connect API, to facilitate communication with the Connect server hosted on your infrastructure and 1Password. The library is intended to be used by your applications, pipelines, and other automations to simplify accessing items stored in your 1Password vaults.

✨ Quickstart

  1. Download and install the 1Password Connect Go SDK:

    go get github.com/1Password/connect-sdk-go
  2. Export the OP_CONNECT_HOST and OP_CONNECT_TOKEN environment variables:

    export OP_CONNECT_HOST=<your-connect-host> && \
        export OP_CONNECT_TOKEN=<your-connect-token>
  3. Use it in your code

    • Read a secret:

      import "github.com/1Password/connect-sdk-go/connect"
      
      func main () {
          client := connect.NewClientFromEnvironment()
          item, err := client.GetItem("<item-uuid>", "<vault-uuid>")
          if err != nil {
              log.Fatal(err)
          }
      }
    • Write a secret:

      import (
          "github.com/1Password/connect-sdk-go/connect"
          "github.com/1Password/connect-sdk-go/onepassword"
      )
      
      func main () {
          client := connect.NewClientFromEnvironment()
          item := &onepassword.Item{
              Title:    "Secret String",
              Category: onepassword.Login,
              Fields: []*onepassword.ItemField{{
                  Value: "mysecret",
                  Type:  "STRING",
              }},
          }
      
          postedItem, err := client.CreateItem(item, "<vault-uuid>")
          if err != nil {
              log.Fatal(err)
          }
      }

For more examples, check out USAGE.md.

💙 Community & Support

🔐 Security

1Password requests you practice responsible disclosure if you discover a vulnerability.

Please file requests by sending an email to bugbounty@agilebits.com.