DEV Community

Discussion on: I Wrote a Go Script to Generate Gists, Here's What I Learned

Collapse
 
pbnj profile image
Peter Benjamin (they/them) • Edited

If I make a web client from which this process would be run, the user would sign in through OAuth with their Github account. This would eliminate the step where they have to manually generate their personal access token and paste it into the CLI.

You could authenticate the user via OAuth in a CLI application.

Checkout hub, which is a CLI also written in Go, to see how they do it, but the UX flows like this:

$ hub clone <user>/<repo>
Github Username:
Github Password (never stored):
...

On first use, hub CLI will require you to authenticate to via your Github credentials, generate a token, and store it in:

$ cat ~/.config/hub
github.com:
- user: petermbenjamin
  oauth_token: [REDACTED]
  protocol: https

All subsequent hub (or git, if you aliased it to git) no longer require authenticate or to explicitly supply a token.

Collapse
 
iwilsonq profile image
Ian Wilson

ahh thank you this is helpful!