Repository navigation
feat: keep OAuth tokens in the OS keychain - #131
Closed
mykytanetipa wants to merge 1 commit into
Closed
mykytanetipa wants to merge 1 commit into
mykytanetipa wants to merge 1 commit into
Conversation
A 0600 file protects tokens from other users but not from other programs running as the same user, backups or synced dotfiles. KeyringStore keeps the tokens in the macOS Keychain, Windows Credential Manager or the Linux Secret Service through zalando/go-keyring, one entry per token to stay within the size limits of the macOS and Windows stores, and everything else in keychain-grants.json, so grants can be listed without reading secrets and the file store never reads a keychain grant as one without tokens. --oauth-store selects the store: file (default) or keychain. Like --oauth-clients, it is not read from a discovered .env. Without a keychain, for example on a headless Linux host with no Secret Service, saving a grant fails and points to --oauth-store file instead of writing the tokens to disk. Refs #98
yarolegovich
reviewed
Nov 6, 2026
| return nil, err | ||
| } | ||
| for i := range grants { | ||
| if err := s.fill(&grants[i]); err != nil { |
Member
There was a problem hiding this comment.
List reads both tokens of every grant from the keychain, but callers only compare keys and then Get the one they picked. let's return index metadata from List and read secrets only in Get
Author
There was a problem hiding this comment.
Fixed in mykytanetipa#7. List reads only the index, which also records whether a grant is refreshable, and secrets are read only in Get. The SDK's Store contract allows List to leave tokens out (a2aproject/a2a-go#569).
Author
|
Closing in favor of the a2a-go OAuth client (a2aproject/a2a-go#568, a2aproject/a2a-go#569, a2aproject/a2a-go#570) and the CLI changes built on it (mykytanetipa#6, mykytanetipa#7). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An owner-only file hides tokens from other users on the machine, not from other programs running as you, backups, or synced dotfiles. This adds an optional keychain store mode that keeps access and refresh tokens in macOS Keychain, Windows Credential Manager, or Linux Secret Service. Plain file storage remains the default.
Example:
Cross-platform keychains accessed through go-keyring only look up entries by key and cannot enumerate stored grants on their own. To support listing and matching grants cleanly, the keychain store keeps non-secret metadata in its own index file, keychain-grants.json, so the file store never mistakes a keychain grant for one without tokens. That metadata covers issuer, client, agent URL, scopes, expiry, and endpoints, while the access and refresh tokens live in the OS keychain as separate entries, which keeps each within the size limits of the macOS and Windows stores.
Saving a grant writes to the keychain before touching the index file on disk. When no keychain service is running, such as on a headless Linux session without Secret Service, or a token is too large for it, the write fails immediately with a message saying which. Rather than quietly falling back to writing tokens to disk, it points the user to the file store.
Fixes #98