You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While building an internal CLI tool with Cobra, I needed to integrate authentication with our backend services using OAuth2. Specifically, I was looking to implement the [device authorization flow](https://datatracker.ietf.org/doc/html/rfc8628). However, I found that there wasn’t an easy-to-use library for this purpose that integrates well with Cobra.
Suggestion
To address this, I started developing a library, [cobra-oauth2](https://github.com/nauthera/cobra-oauth2), aimed at simplifying the integration of OAuth2 flows into Cobra-based CLI tools. The library is in its early stages and currently supports basic features, but it is designed to be easy to use and extend.
Here’s a basic example of how to use cobra-oauth2:
Example Usage
1. Main Application Setup
Define your main entry point and execute your Cobra CLI:
package main
import"github.com/nauthera/cobra-oauth2/examples/basic/cmd"funcmain() {
cmd.Execute()
}
2. Root Command Setup
Set up the root command and initialize OAuth2 commands:
Is there a specific need or demand for an OAuth2 library that integrates seamlessly with Cobra?
Does Cobra’s core maintainers or the community recommend any existing solutions I may have overlooked?
Would it make sense to provide guidance on how to handle such cases?
Contribution
I’d love feedback on the design and implementation of cobra-oauth2. Contributions and ideas for extending its capabilities (e.g., support for additional OAuth2 flows, enhanced storage mechanisms, etc.) are welcome!
While building an internal CLI tool with Cobra, I needed to integrate authentication with our backend services using OAuth2. Specifically, I was looking to implement the [device authorization flow](https://datatracker.ietf.org/doc/html/rfc8628). However, I found that there wasn’t an easy-to-use library for this purpose that integrates well with Cobra.
Suggestion
To address this, I started developing a library, [cobra-oauth2](https://github.com/nauthera/cobra-oauth2), aimed at simplifying the integration of OAuth2 flows into Cobra-based CLI tools. The library is in its early stages and currently supports basic features, but it is designed to be easy to use and extend.
Here’s a basic example of how to use
cobra-oauth2
:Example Usage
1. Main Application Setup
Define your main entry point and execute your Cobra CLI:
2. Root Command Setup
Set up the root command and initialize OAuth2 commands:
Question for the Community
Contribution
I’d love feedback on the design and implementation of
cobra-oauth2
. Contributions and ideas for extending its capabilities (e.g., support for additional OAuth2 flows, enhanced storage mechanisms, etc.) are welcome!Repo: https://github.com/nauthera/cobra-oauth2
The text was updated successfully, but these errors were encountered: