{"action":"opened","issue":{"url":"https://api.github.com/repos/magit/magit/issues/2973","repository_url":"https://api.github.com/repos/magit/magit","labels_url":"https://api.github.com/repos/magit/magit/issues/2973/labels{/name}","comments_url":"https://api.github.com/repos/magit/magit/issues/2973/comments","events_url":"https://api.github.com/repos/magit/magit/issues/2973/events","html_url":"https://github.com/magit/magit/issues/2973","id":203235490,"number":2973,"title":"Promote a common approach to storing Github/Gitlab/Bitbucket credentials","user":{"login":"tarsius","id":25046,"avatar_url":"https://avatars.githubusercontent.com/u/25046?v=3","gravatar_id":"","url":"https://api.github.com/users/tarsius","html_url":"https://github.com/tarsius","followers_url":"https://api.github.com/users/tarsius/followers","following_url":"https://api.github.com/users/tarsius/following{/other_user}","gists_url":"https://api.github.com/users/tarsius/gists{/gist_id}","starred_url":"https://api.github.com/users/tarsius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarsius/subscriptions","organizations_url":"https://api.github.com/users/tarsius/orgs","repos_url":"https://api.github.com/users/tarsius/repos","events_url":"https://api.github.com/users/tarsius/events{/privacy}","received_events_url":"https://api.github.com/users/tarsius/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-01-25T22:02:55Z","updated_at":"2017-01-25T22:02:55Z","closed_at":null,"body":"I believe there are currently two Elisp libraries for accessing the Github api; [`gh`](https://github.com/sigma/gh.el) and my [`ghub`](https://github.com/tarsius/ghub).  And I am sure some end-user packages come with their own tools for accessing the api.  This is all perfectly fine, but for users who use multiple packages by different authors it is inconvenient to have to setup the credentials multiple times.  In `ghub` I made an effort to leverage existing Emacs features instead of reinventing the wheel.\r\n\r\nThese are the setup instructions:\r\n\r\n```\r\n;; Initial configuration:\r\n;;\r\n;;   $ git config github.user <username>\r\n;;   $ emacs ~/.authinfo.gpg\r\n;;   # -*- epa-file-encrypt-to: (\"A.U.Thor@example.com\") -*-\r\n;;   machine api.github.com login <login> password <token>\r\n```\r\n\r\nNote very chatty, but quite self-explanatory I hope.  And all the code related to this in `ghub.el` is this:\r\n\r\n```lisp\r\n(require 'auth-source)\r\n\r\n(defun ghub--get-access-token ()\r\n  (let ((secret\r\n         (plist-get (car (auth-source-search\r\n                          :max 1\r\n                          :user (substring (shell-command-to-string\r\n                                            \"git config github.user\")\r\n                                           0 -1)\r\n                          :host ghub--domain))\r\n                    :secret)))\r\n    (if (functionp secret)\r\n        (funcall secret)\r\n      secret)))\r\n```\r\n\r\n(Note how I did not even use Magit when calling `git' ;-)\r\n\r\nI have seen other packages doing essentially the same in a much more complicated fashion, for both the user as well as the author.  You don't need to depend on `ghub` to do use its approach, it might not be to your taste (and is subject to change (likely only better error handling, but the use of `libcurl` is also on the table)).  Please feel free to copy-paste this snippet into your package instead.\r\n\r\n----\r\n\r\nNote that the same applies to Gitlab (my `glab.el` is almost identical to `ghub.el` except `s/ghub/glab/`), and Bitbucket.\r\n\r\n----\r\n\r\nPlease also note that I have not yet invited any of the involved parties to this conversation because I am currently trying to outline my future work on Magit and opening many issues in the process.  Only once I am done with that, will I actually try to get this conversation going."}}
{"actor":{"display_login":"tarsius"}}