{"id":18451977,"url":"https://github.com/keybase/go-keychain","last_synced_at":"2025-05-14T07:09:50.523Z","repository":{"id":1765284,"uuid":"43088890","full_name":"keybase/go-keychain","owner":"keybase","description":"Golang keychain package for iOS and macOS","archived":false,"fork":false,"pushed_at":"2025-02-27T17:57:00.000Z","size":14158,"stargazers_count":601,"open_issues_count":16,"forks_count":124,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-04-13T08:58:17.472Z","etag":null,"topics":["golang","ios","keychain","macos"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keybase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-09-24T19:41:15.000Z","updated_at":"2025-04-09T13:42:04.000Z","dependencies_parsed_at":"2024-12-21T02:01:51.784Z","dependency_job_id":"8bd61c1e-81f4-4db4-9d7b-88858a805655","html_url":"https://github.com/keybase/go-keychain","commit_stats":{"total_commits":110,"total_committers":21,"mean_commits":5.238095238095238,"dds":0.6545454545454545,"last_synced_commit":"57a3676c3af6b63bc7f885e1069dc6f53d273277"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keybase%2Fgo-keychain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keybase%2Fgo-keychain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keybase%2Fgo-keychain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keybase%2Fgo-keychain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keybase","download_url":"https://codeload.github.com/keybase/go-keychain/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254092788,"owners_count":22013290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","ios","keychain","macos"],"created_at":"2024-11-06T07:29:50.233Z","updated_at":"2025-05-14T07:09:45.512Z","avatar_url":"https://github.com/keybase.png","language":"Go","readme":"# Go Keychain\n\n[![Build Status](https://github.com/keybase/go-keychain/actions/workflows/ci.yml/badge.svg)](https://github.com/keybase/go-keychain/actions)\n\nA library for accessing the Keychain for macOS, iOS, and Linux in Go (golang).\n\nRequires macOS 10.9 or greater and iOS 8 or greater. On Linux, communicates to\na provider of the DBUS SecretService spec like gnome-keyring or ksecretservice.\n\n```go\nimport \"github.com/keybase/go-keychain\"\n```\n\n## Mac/iOS Usage\n\nThe API is meant to mirror the macOS/iOS Keychain API and is not necessarily idiomatic go.\n\n#### Add Item\n\n```go\nitem := keychain.NewItem()\nitem.SetSecClass(keychain.SecClassGenericPassword)\nitem.SetService(\"MyService\")\nitem.SetAccount(\"gabriel\")\nitem.SetLabel(\"A label\")\nitem.SetAccessGroup(\"A123456789.group.com.mycorp\")\nitem.SetData([]byte(\"toomanysecrets\"))\nitem.SetSynchronizable(keychain.SynchronizableNo)\nitem.SetAccessible(keychain.AccessibleWhenUnlocked)\nerr := keychain.AddItem(item)\n\nif err == keychain.ErrorDuplicateItem {\n  // Duplicate\n}\n```\n\n#### Query Item\n\nQuery for multiple results, returning attributes:\n\n```go\nquery := keychain.NewItem()\nquery.SetSecClass(keychain.SecClassGenericPassword)\nquery.SetService(service)\nquery.SetAccount(account)\nquery.SetAccessGroup(accessGroup)\nquery.SetMatchLimit(keychain.MatchLimitAll)\nquery.SetReturnAttributes(true)\nresults, err := keychain.QueryItem(query)\nif err != nil {\n  // Error\n} else {\n  for _, r := range results {\n    fmt.Printf(\"%#v\\n\", r)\n  }\n}\n```\n\nQuery for a single result, returning data:\n\n```go\nquery := keychain.NewItem()\nquery.SetSecClass(keychain.SecClassGenericPassword)\nquery.SetService(service)\nquery.SetAccount(account)\nquery.SetAccessGroup(accessGroup)\nquery.SetMatchLimit(keychain.MatchLimitOne)\nquery.SetReturnData(true)\nresults, err := keychain.QueryItem(query)\nif err != nil {\n  // Error\n} else if len(results) != 1 {\n  // Not found\n} else {\n  password := string(results[0].Data)\n}\n```\n\n#### Delete Item\n\nDelete a generic password item with service and account:\n\n```go\nitem := keychain.NewItem()\nitem.SetSecClass(keychain.SecClassGenericPassword)\nitem.SetService(service)\nitem.SetAccount(account)\nerr := keychain.DeleteItem(item)\n```\n\n### Other\n\nThere are some convenience methods for generic password:\n\n```go\n// Create generic password item with service, account, label, password, access group\nitem := keychain.NewGenericPassword(\"MyService\", \"gabriel\", \"A label\", []byte(\"toomanysecrets\"), \"A123456789.group.com.mycorp\")\nitem.SetSynchronizable(keychain.SynchronizableNo)\nitem.SetAccessible(keychain.AccessibleWhenUnlocked)\nerr := keychain.AddItem(item)\nif err == keychain.ErrorDuplicateItem {\n  // Duplicate\n}\n\npassword, err := keychain.GetGenericPassword(\"MyService\", \"gabriel\", \"A label\", \"A123456789.group.com.mycorp\")\n\naccounts, err := keychain.GetGenericPasswordAccounts(\"MyService\")\n// Should have 1 account == \"gabriel\"\n\nerr := keychain.DeleteGenericPasswordItem(\"MyService\", \"gabriel\")\nif err == keychain.ErrorItemNotFound {\n  // Not found\n}\n```\n\n## iOS\n\nBindable package in `bind`. iOS project in `ios`. Run that project to test iOS.\n\nTo re-generate framework:\n\n```\n(cd bind \u0026\u0026 gomobile bind -target=ios -tags=ios -o ../ios/bind.framework)\n```\n\nPost issues to: https://github.com/keybase/keybase-issues\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeybase%2Fgo-keychain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeybase%2Fgo-keychain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeybase%2Fgo-keychain/lists"}