New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`auth-source-search` not returning `:secret` in Emacs 25.2.2 #64

Closed
rneatherway opened this Issue Aug 3, 2018 · 3 comments

Comments

2 participants
@rneatherway

rneatherway commented Aug 3, 2018

I had a little struggle to debug why I was always getting prompted to create a token when calling ghub-get and friends. I found in the end that the call to auth-source-search in ghub--auth-source-get doesn't return any value for the :secret key when :max 1 is passed. If :max 2 or higher is passed or the argument is not passed then :secret is present. With Emacs 26.1 this works as expected.

My .authinfo file is as follows:

machine api.github.com login rneatherway^ghub password 11111..

I raise this here because I saw you said in #57 that this package patches auth-source. Let me know if I can provide any further information.

@tarsius

This comment has been minimized.

Member

tarsius commented Aug 3, 2018

The :max was added in response to #24. However that issue mentions that :max should come last, which I seem to have ignored. Please try this patch:

diff --git a/ghub.el b/ghub.el
index 4894e7b..b6b1ef8 100644
--- a/ghub.el
+++ b/ghub.el
@@ -683,8 +683,8 @@ (defun ghub--token (host username package &optional nocreate forge)
                 ;; value, but in our case that is a situation that needs
                 ;; fixing so we want to keep trying by invalidating that
                 ;; information.  The (:max 1) is needed for Emacs releases
-                ;; before 26.1.
-                (auth-source-forget (list :max 1 :host host :user user))
+                ;; before 26.1. #24 #64
+                (auth-source-forget (list :host host :user user :max 1))
                 (and (not nocreate)
                      (if (eq forge 'gitlab)
                          (error
@@ -819,7 +819,8 @@ (defun ghub--read-2fa-code ()
 
 (defun ghub--auth-source-get (keys &rest spec)
   (declare (indent 1))
-  (let ((plist (car (apply #'auth-source-search :max 1 spec))))
+  (let ((plist (car (apply #'auth-source-search
+                           (append spec (list :max 1))))))
     (mapcar (lambda (k)
               (plist-get plist k))
             keys)))
@rneatherway

This comment has been minimized.

rneatherway commented Aug 5, 2018

That works perfectly, thanks.

Thanks for all your hard work on magit, I use it everyday at work and it saves me so much time! I supported your Kickstarter and I'd be happy to do so again.

@tarsius tarsius closed this in ec27f84 Aug 5, 2018

@tarsius

This comment has been minimized.

Member

tarsius commented Aug 5, 2018

You're weclome and thanks!

@tarsius tarsius reopened this Aug 5, 2018

@tarsius tarsius closed this Aug 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment