This is rather basic oauth token support. The most interesting part is probably the curl command to generate an oauth token that can create gists.
It should help address the security concerns in defunkt#84, though.
Allow the use of an oauth token to create gists
gitjub.token doesn't work anymore. Do we need it here? I remove that code.
It's being used here to warn about the change in authentication; removing it is out of the scope of this change.
why hasn't this been merged? seems to work well
Three ways? password/oauth and env-var/git-config, 2*2=4.
Besides, is it necessary to support both password and oauth token?
Requiring a manual curl call by the user is pretty rough, IMO.
I would recommend checking out @mislav's approach in the OAuth update to defunkt/hub: https://github.com/defunkt/hub/compare/api-v3
That prompts the user for a password, then uses that only to retrieve and cache the OAuth token.
See also defunkt/hub#163
I'm open to suggestions for extracting a small common utility that does it that hub and gist commands can share so we don't implement the same thing twice.
hub doesn't have external dependencies, so it would have to be a simple embeddable Ruby script.
I agree; the curl call is miserable. My primary concern was getting the oauth functionality in place, but bringing a better experience to it would be well worthwhile.
mislav, the most general way that immediately occurs to me to split the token handler out would be a higher-level github API module than you have in hub - basically, only the api request functionality (get and post, and their underpinnings) and the capability to generate a token with the right permissions if one can't be found. That could then be the basis for the rest of your github API functionality, and start as the way to handle tokens in gist (but possibly move to standardize all of the git API handling in it as well). Thoughts?
Here's the GitHub API client support code that I just released in hub. Maybe you can copy it over to gist, or mark "hub" gem as a dependency for gist (that wouldn't work when installed via brew, though).
The code is extremely modular and non-specific to hub. You could configure it to store oauth_token in "~/.config/gist".
If you have any feedback regarding my code (it's not perfect, quickly hacked together in order to ship), let me know.
Try using my PR (#130) - it includes support for multiple API Providers (GH:E & GitHub.com), and includes functionality to auto-generate and store Github/GH:E credential (token) information.