0

I have a deployed server (https://github.com/nicolsc/slack-sigfox-last-message/blob/master/server.js) and I need to set a URL like the one below to integrate a slack command:

http://{user}:{password}@serverurl.com/{slack route}

My question is, which user name and password do I need? My Pc? The server's? Also, the server URL should be like localhost:400XX.com?

Sorry if the question is not too clear but this is brand new to me, so any kind of help is really appreciated.

EDIT: I already build a config.local.js file to configure all .env entries. When I run npm start and browse the localhost I get somthing like this: Browsed localhost

And when I type the Login/password, I get this response from the npm:

slackbot-sigfox-last-message:debug { host: 'localhost:34005', connection: 'keep-alive', 'cache-control': 'max-age=0', authorization: 'Basic NTdjOWI4MWM5ZTkzYTE2Y2QyODg1ZmJlOjZkYjYxNzMwNTE1NWIzZjE3OTRjMGM2ZDI5MjE3MmY1', 'upgrade-insecure-requests': '1', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36', accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp, /;q=0.8', 'accept-encoding': 'gzip, deflate, sdch', 'accept-language': 'es-ES,es;q=0.8,en;q=0.6' } +0ms

slackbot-sigfox-last-message:debug Invalid slack token +2ms

slackbot-sigfox-last-message:debug {} +0ms

slackbot-sigfox-last-message:sigfox Error +1ms

slackbot-sigfox-last-message:sigfox { message: 'Invalid Slack Token' } +0ms

So apparently, the token is what is not right and I've been told it's because of the URL not being set correctly, that's my point.

Dennis R
  • 1,769
  • 12
  • 13
Jaime FH
  • 39
  • 1
  • 10

1 Answers1

0

Look at the auth.js in the project. Login and passwords are retrieved from environment variables:

process.env.LOGIN
process.env.PASSWORD

There are multiple options to set up environment variables. You can edit package.json and update scripts.start with "start": "LOGIN=user PASSWORD=123 node server.js". Or in Linux you can do: export LOGIN=user and the check variable by: echo $LOGIN

See also here

As stated in documentaion url should be:http://localhost:34005

As you figured out config.local.js is required with content:

module.exports = {
    "LOGIN" : "a",
   "PASSWORD" : "b",
   "SLACK_TOKEN" : 111,
    "SLACK_ROUTE" : "aaa" 
}

You can also try to disable authentication in server.js

Community
  • 1
  • 1
Dennis R
  • 1,769
  • 12
  • 13
  • I edited to make it clearer, what you said is right. – Jaime FH Sep 09 '16 at 16:09
  • You need token from slack, see auth.js – Dennis R Sep 09 '16 at 16:18
  • There is additional slack authentication. Another variable should be added to env: SLACK_TOCKEN, and it should be present in request(req.body.token) You can debug node and check this. – Dennis R Sep 09 '16 at 16:25
  • The SLACK_TOKEN is in the config.js, how can I make sure it's the same as the req.body.token? It seems the debug is on (DEBUG: 'slackbot-sigfox-last-message:*' //config.js) – Jaime FH Sep 09 '16 at 16:39
  • when you do http post request it should have header: --header "Content-Type: application/json" and body should be json with token {"token": "xxxx"}(use some http tool like postman), you can try to comment out authentication for now: //app.use("*", auth.basic); //app.use("*", auth.slack); – Dennis R Sep 09 '16 at 16:48
  • Please accept the answer if you think I answered your question. You can ask separate questions for other details. – Dennis R Sep 09 '16 at 17:17
  • Thanks, this was quite helpful. Would you mind helping me run it? I don't mind opening other questions, it's just commenting out àpp.use`isn't doing the trick. I tried bringing down the authentication but it keeps bringing the 'Invalid slack token' thing. – Jaime FH Sep 09 '16 at 18:02
  • You can debug your node app and see value of the token, are you sending post request with basic authentication and json content? – Dennis R Sep 09 '16 at 18:28
  • I don't know how to debug it to see the token nor how the post request looks like. If you mean the config.js, it is in json format and fulfills each label. – Jaime FH Sep 09 '16 at 18:48