Skip to content

Conversation

@kumarmunish
Copy link

@kumarmunish kumarmunish commented Jul 15, 2025

Fixes #1

📄 Summary

This PR adds a new section to the README.md titled "OAuth Guidance for CLI and Headless Apps", providing clear guidance on handling OAuth Client ID and Secret in public clients such as CLI tools.

It incorporates recommendations made by maintainers in Issue #1, highlighting:

  • Why embedding secrets in public clients is acceptable
  • The limitations of protecting secrets in client-side binaries
  • The preferred use of GitHub's Device Flow for CLI authorization
  • Basic mitigation techniques like rate limiting and usage monitoring

📝 Changes

  • 📘 Added a new section to README.md with practical guidance for OAuth in public clients
  • 🔗 Linked to GitHub's official Device Flow documentation
  • 🧠 Incorporated insights from @mislav and GitHub CLI patterns

🔍 Related Issues

Fixes or completes: #1


✅ Checklist

  • Follows repo formatting and section style
  • Reflects official maintainer guidance
  • Improves clarity for CLI tool developers
  • No breaking changes introduced

🙋‍♂️ Notes for Reviewers

The goal here is to formalize guidance that was already shared in Issue #1 but never documented. Feedback welcome on tone or placement within the README.

@kumarmunish
Copy link
Author

kumarmunish commented Jul 22, 2025

Hey @williammartin, mind taking a quick look at this when you're free? Appreciate your feedback!

@andyfeller andyfeller self-requested a review July 22, 2025 14:27
@andyfeller
Copy link
Member

Thank you for the contribution, @kumarmunish! ❤️ Will asked me to follow up on this review.

Copy link
Member

@andyfeller andyfeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for creating the momentum to close out #1, @kumarmunish! 🫶 After careful consideration, I strongly believe this guidance needed a different approach.

Application developers should understand their security needs and choose the appropriate OAuth authentication flow. As such, the GitHub CLI maintainers should be cautious about making a blanket statement that all CLIs and headless applications follow the same approach we have.

To that effect, I've updated the content instead to explain the circumstances and considerations for why the GitHub CLI manages its client identification that way it does. Hopefully this and information from the original OAuth IETF specification will help other developers make an appropriate decision for themselves.

Comment on lines 26 to 39
## Managing OAuth Client Identifier

CLIs or headless applications using [device flow][gh-device] are considered [public clients][rfc-client-types]:

> _Clients incapable of maintaining the confidentiality of their credentials (e.g., clients executing on the device used by the resource owner, such as an installed native application or a web browser-based application), and incapable of secure client authentication via any other means._
For this reason, the GitHub CLI has its OAuth client information committed to `cli/cli` source code as:

1. `gh` releases are publicly distributed and can be decompiled to retrieve this information
2. `gh` has semi-officially supported `go install` installation as described in [cli/cli#9912](https://github.com/cli/cli/issues/9912)

Applications using [web application flow][gh-web] must keep the OAuth client secret confidential.

For more information, see [cli/oauth#1](https://github.com/cli/oauth/issues/1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: I think it is important for GitHub to be more conservative in the guidance here, focusing on why gh is being managed the way it is.

Again, the GitHub CLI maintainers cannot speak to all other CLI and headless application use cases, only the decisions we've made the reasoning for it.

@andyfeller andyfeller self-assigned this Jul 22, 2025
@andyfeller andyfeller self-requested a review July 22, 2025 14:51
Copy link
Member

@BagToad BagToad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andyfeller LGTM and makes sense. Thanks for shaping this up 🙏

@kumarmunish
Copy link
Author

Thanks a lot for refining the docs, @andyfeller 🙌
Your updates made the content sharper and more to the point. Really appreciate the approach and clarity you've brought in — it's a great improvement, and I’ve learned a lot from the way you framed things!!

@andyfeller
Copy link
Member

@kumarmunish : after internal discussion with the GitHub Apps team, we've decided to update GitHub Docs "Secure your app's credentials" for the necessary guidance in a central place used by all GitHub users.

thank you again for taking the time opening up this PR!

@andyfeller andyfeller closed this Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How should OAuth Client IDs be distributed to headless apps?

3 participants