Skip to content
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

Unable to authorize client #268

Open
yllekz opened this issue Jan 24, 2022 · 14 comments
Open

Unable to authorize client #268

yllekz opened this issue Jan 24, 2022 · 14 comments

Comments

@yllekz
Copy link

yllekz commented Jan 24, 2022

Despite making a file containing my token as ~/.config/slack-term/config/.slack-term, I get this error:

2022/01/24 18:24:59 not able to authorize client, check your connection and if your slack-token is set correctly

This is my file:

{
    "slack_token": "mytokenwashere"
}

What is the issue?


Version: 0.5.0
Installation method: sudo snap install slack-term

@rkpatel33
Copy link

Same issue, the Docker container works and can connect to my Slack account, but the binary does not. My config file is located at the following per the README:

~/.config/slack-term/config\

@natefduncan
Copy link

I experience the same issue but can get it to work if I specify the config location with the -config flag: slack-term -config ~/.slack-term or slack-term -config ~/.config/slack-term/config.

@yllekz
Copy link
Author

yllekz commented Feb 25, 2022

Update: I apparently had comments in my config file (JSON doesn't support comments and neither does the app).

I got this to work:

sudo docker run -it -v ~/.config/slack-term/config/.slack-term:/config erroneousboat/slack-term

But this still does not work:
slack-term -config ~/.config/slack-term/config/.slack-term

I will happily use the Docker container though.

@hallvors
Copy link

I wanted to test slack-term and I get this error too.

First attempt with method 4 (window.promt() trick, very clever :) ), then method 2 https://github.com/erroneousboat/slack-term/wiki#method-2 . I got two different tokens, and neither of them worked :(

$ docker run -sh -v /home/[username]/.config/slack-term/config:/config erroneousboat/slack-term
2022/04/27 08:45:26 not able to authorize client, check your connection and if your slack-token is set correctly
$ ./slack-term-linux-amd64
2022/04/27 10:46:44 not able to authorize client, check your connection and if your slack-token is set correctly

@hallvors
Copy link

(I also ran docker run -sh -v /home/[username]/.config/slack-term/config:/config --entrypoint /bin/sh erroneousboat/slack-term to check that the config file was mounted correctly in /config with the token, and that I could ping servers on the 'net from inside the container - just in case. All seemed fine.)

@lepe
Copy link

lepe commented May 11, 2022

First, the default config file is in ./config/slack-term/config (its a file, not a directory).

When installing it via snap, that config file is stored in:

~/snap/slack-term/current/.config/slack-term/config

(you can confirm as it is created automatically).

You need to edit that file and add your token there. You can also add other config options as specified.

When updating slack-term that file is very likely to be removed, so keep a copy somewhere.

@shydefoo
Copy link

Facing the same issue when using docker and from my local. My config is set correctly,

{
  "slack_token": "mytoken"
}
➜ slack-term -config ~/.config/slack-term/config
2022/06/22 08:28:25 not able to authorize client, check your connection and if your slack-token is set correctly

Anyone still facing this problem?

@Seanld
Copy link

Seanld commented Aug 9, 2022

Yes, I did some digging around in the code, and it turns out @bagnaram in #136 is correct.

The library that slack-term uses to interface with the official API is slack-go, but that (as far as I can tell) does not support this particular authentication method (xoxc token + xoxd token in Cookie header).

After cloning this repo, and cloning slack-go, and then forcing slack-term to use my local version of slack-go, and then modifying slack-go to shove my own personal xoxd token into the Cookie parameter in the headers of the API request, I was able to get slack-term connected.

slack-go will need a change to allow passing in and setting that particular header parameter in API requests.

slack-term will need a change to add a config option for the xoxd token that the user must also fetch somehow (easiest from the dev tools in the browser, I find). And it will need to pass that to slack-go when it creates a new API connection.

So, in summary, it's a two-headed problem. This app doesn't supply the xoxd token, and even if it did, the library it uses doesn't have the facilities to handle that. I'm going to try and work on an MR to submit here, and one to submit to slack-go.

I'm not sure why this doesn't seem to be a bigger issue for more people. Some comments in various threads on this problem mention that it's only newer workspaces. That seems like the most likely explanation.

@pandruszkow
Copy link

I'm affected by the same issue.

@robrecord
Copy link

robrecord commented Dec 15, 2022

Thank you @Seanld . Would love to see a fix for this issue.

In slack-go they are working on something at slack-go/slack#1092

@ceandreasen
Copy link

I was able to bodge together a working proof of concept together by copying the chttp implementation from slackdump, which was referenced in the last comment of the above linked issue 1092

If it ends up meeting my needs, I'll try to put together a more proper implementation that takes the cookie as a config value rather than hardcoding it, though I don't really know Go so we'll see.

@thomas-scrace
Copy link

I have this problem too.

@ceandreasen
Copy link

ceandreasen commented Aug 30, 2023

@thomas-scrace sorry for the slow reply. I have a working version here in my fork. It's still messy but you can now specify the additional token from the config value slack_xoxd_token and it's been working for me all summer.

I had to do some funny stuff with dependencies to make it work that I don't really recall the details of any more, probably not all up to snuff at all, but if someone who knows how Go works wants to clean it up be my guest.

@hbak
Copy link

hbak commented Oct 30, 2023

^ ceandreasen's fork works.
Instructions on how to get xoxd token on this other project's readme: https://github.com/NoF0rte/slack-slurp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests