yuya373 / emacs-slack

slack client for emacs
1.11k stars 117 forks source link

Getting "Failed to request slack-authorize: invalid_auth" When Using 'M-x slack-start' With '~/.authinfo' File #562

Open SamuelBanya opened 2 years ago

SamuelBanya commented 2 years ago

Hello,

I'm getting the the following error when I run 'M-x slack-start' on my Macbook Pro using Emacs 27.2. Failed to request slack-authorize: invalid_auth

Here's my ~/.authinfo, modified to not show any important info: machine host.slack.com login my@email.com password "mySecretPasswordToken"

Here's my literate Emacs config (modified to not show any important info):

*** Install 'slack' package
#+BEGIN_SRC emacs-lisp
  ;; Adding this ONLY for Macbook:
  (when (string= system-name "myComputerName")
    (use-package slack
      :ensure t
      :init
      (setq slack-prefer-current-team t)
      :config
      (slack-register-team
       :name "mySlackTeamName"
       :default t
       :token (auth-source-pick-first-password
           :host "host.slack.com"
           :user "my@email.com"))))
#+END_SRC

*** Set the 'auth-sources' variable for 'slack'
#+BEGIN_SRC emacs-lisp
  ;; Adding this ONLY for Macbook:
  (when (string= system-name "myComputerName")
    (setq auth-sources '("~/.authinfo")))
#+END_SRC
*** Add 'circe' as 'emacs-slack' dependency
#+BEGIN_SRC emacs-lisp
  ;; Adding this ONLY for Macbook:
  (when (string= system-name "myComputerName")
    (use-package circe
      :ensure t))
#+END_SRC
*** Add 'emojify' as 'emacs-slack' dependency
#+BEGIN_SRC emacs-lisp
  ;; Adding this ONLY for Macbook:
  (when (string= system-name "myComputerName")
    (use-package emojify
      :ensure t))
#+END_SRC
*** Add 'oauth2' as 'emacs-slack' dependency
#+BEGIN_SRC emacs-lisp
  ;; Adding this ONLY for Macbook:
  (when (string= system-name "myComputerName")
    (use-package oauth2
      :ensure t))
#+END_SRC
*** Add 'alert' as 'emacs-slack' dependency
#+BEGIN_SRC emacs-lisp
  ;; Adding this ONLY for Macbook:
  (when (string= system-name "myComputerName")
    (use-package alert
      :commands (alert)
      :init
      (setq alert-default-style 'notifier)))
#+END_SRC
*** Add 'request' as 'emacs-slack' dependency
#+BEGIN_SRC emacs-lisp
  ;; Adding this ONLY for Macbook:
  (when (string= system-name "myComputerName")
    (use-package request
      :ensure t))
#+END_SRC
*** Add 'websocket' as 'emacs-slack' dependency
#+BEGIN_SRC emacs-lisp
  ;; Adding this ONLY for Macbook:
  (when (string= system-name "myComputerName")
    (use-package websocket
      :ensure t))
#+END_SRC

Am I missing anything in my config?

I used 'M-x package-refresh-contents' to make sure I'm using the latest version if that helps.

Thanks,

Sam

SamuelBanya commented 2 years ago

I recently digged into previous issues, and found this one:

With this in mind, I made this revision to my '~/.emacs.d/configuration.org' config:

*** Install 'slack' package
#+BEGIN_SRC emacs-lisp
  ;; Adding this ONLY for Macbook:
  (when (string= system-name "myComputerName")
    (use-package slack
      :ensure t
      :init
      (setq slack-prefer-current-team t)
      :config
      (slack-register-team
       :name "teamName"
       :default t
       :token (auth-source-pick-first-password
           :host '("host.slack.com")
           :user "token"
           :type 'netrc
           :max 1))))
#+END_SRC

*** Set the 'auth-sources' variable for 'slack'
#+BEGIN_SRC emacs-lisp
  ;; Adding this ONLY for Macbook:
  (when (string= system-name "myComputerName")
    (setq auth-sources '("~/.authinfo")))
#+END_SRC
*** Add 'circe' as 'emacs-slack' dependency
#+BEGIN_SRC emacs-lisp
  ;; Adding this ONLY for Macbook:
  (when (string= system-name "myComputerName")
    (use-package circe
      :ensure t))
#+END_SRC
*** Add 'emojify' as 'emacs-slack' dependency
#+BEGIN_SRC emacs-lisp
  ;; Adding this ONLY for Macbook:
  (when (string= system-name "myComputerName")
    (use-package emojify
      :ensure t))
#+END_SRC
*** Add 'oauth2' as 'emacs-slack' dependency
#+BEGIN_SRC emacs-lisp
  ;; Adding this ONLY for Macbook:
  (when (string= system-name "myComputerName")
    (use-package oauth2
      :ensure t))
#+END_SRC
*** Add 'alert' as 'emacs-slack' dependency
#+BEGIN_SRC emacs-lisp
  ;; Adding this ONLY for Macbook:
  (when (string= system-name "myComputerName")
    (use-package alert
      :commands (alert)
      :init
      (setq alert-default-style 'notifier)))
#+END_SRC
*** Add 'request' as 'emacs-slack' dependency
#+BEGIN_SRC emacs-lisp
  ;; Adding this ONLY for Macbook:
  (when (string= system-name "myComputerName")
    (use-package request
      :ensure t))
#+END_SRC
*** Add 'websocket' as 'emacs-slack' dependency
#+BEGIN_SRC emacs-lisp
  ;; Adding this ONLY for Macbook:
  (when (string= system-name "myComputerName")
    (use-package websocket
      :ensure t))
#+END_SRC

I then changed my ~/.authinfo to this: machine host.slack.com login token password "reallyLongToken"

Unfortunately, I am still running into the same issue: Failed to request slack-authorize: invalid_auth

matthew-piziak commented 2 years ago

I don't this this is due to auth-source because I get the same error even if I invoke slack-register-team directly.

matthew-piziak commented 2 years ago

I tried again and now I can auth. I must have made a mistake in the setup the first time.