Repository navigation
gh auth logout does not erase and/or revoke OAuth token in MacOS Keychain #13111
Description
Activity
Thanks for reporting this, @fproulx-boostsecurity! 🙏
This is a valid bug. When you answer "Yes" to "Authenticate Git with your GitHub credentials?" during
gh auth login, we store the token in your configured git credential helper (in your case,osxkeychain) viagit credential approve. However,gh auth logoutonly clears credentials from our own internal storage and never callsgit credential rejectto clean up what we put in the external helper.Interestingly, we already call
git credential rejectduring login (to clear any previously stored credential before writing the new one), so the mechanism is there. We just need to also invoke it on logout.One edge case worth noting:
git credential rejectremoves credentials by protocol and host, so if someone manually replaced the credential in the external helper aftergh auth login, calling reject on logout would remove that too. In practice though, this is a super unlikely scenario, and since the login flow already overwrites any pre-existing credentials for that slot, it's safer to proceed with the rejection on logout for consistency.In the meantime, you can work around this by running
gh auth setup-git, which configuresghitself as the credential helper for GitHub hosts. That way, git delegates credential lookups togh, and logout works as expected because there's nothing stored externally to clean up.- addedbugSomething isn't workingSomething isn't workingpriority-3Affects a small number of users or is largely cosmeticAffects a small number of users or is largely cosmeticgh-authrelating to the gh auth commandrelating to the gh auth command
on May 11, 2026 - addedauthrelated to tokens, authentication state, or oauthrelated to tokens, authentication state, or oauth
on May 11, 2026 I just made a draft PR (#13450) for this. I haven't fully checked it yet, but feel free to review and if it looks sound to you try building
ghand test it, @fproulx-boostsecurity.Reacted by François Proulxfproulx-boostsecurity commented
on May 26, 2026 AuthorMore actionsThanks @babakks !
@babakks I opened #14362 to address both revocation and keychain cleanup, but I'm being told it doesn't satisfy requirements since it doesn't reference a
help wantedissue. I also referenced #9233 but that also doesn't havehelp wanted.If you can clarify whether that's a hard requirement or something that can be worked around, would really appreciate it. The PR has very clear documentation on how to test.
Describe the bug
On MacOS, using
ghwith OSX Keychain,gh auth logoutdoes not erase the token from keychain.Affected version
Steps to reproduce the behavior
Expected vs actual behavior
I expect, at the very least, the OAuth token to be removed from MacOS keychain, ideally revoked using REST API.