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

ERROR: Unauthorized #33

Closed
arm4b opened this issue Aug 3, 2015 · 11 comments
Closed

ERROR: Unauthorized #33

arm4b opened this issue Aug 3, 2015 · 11 comments

Comments

@arm4b
Copy link
Member

arm4b commented Aug 3, 2015

Running it on production with authentication enabled. At start it works ok, but after some period of time when trying to run chatops command I get:

error

Version:
hubot-stackstorm 0.2.1

Log:

[Wed Jul 29 2015 16:50:44 GMT+0000 (UTC)] INFO Connecting...
[Wed Jul 29 2015 16:50:44 GMT+0000 (UTC)] INFO Logged in as chatopsbot of ..., but not yet connected
[Wed Jul 29 2015 16:50:45 GMT+0000 (UTC)] INFO Slack client now connected
[Wed Jul 29 2015 16:50:45 GMT+0000 (UTC)] INFO Performing authentication...
[Wed Jul 29 2015 16:50:45 GMT+0000 (UTC)] INFO /opt/hubot/node_modules/hubot-stackstorm/scripts/stackstorm.js is using deprecated documentation syntax
[Wed Jul 29 2015 16:50:45 GMT+0000 (UTC)] INFO hubot-redis-brain: Using default redis on localhost:6379
[Wed Jul 29 2015 16:50:45 GMT+0000 (UTC)] INFO Loading commands....
[Wed Jul 29 2015 16:50:45 GMT+0000 (UTC)] INFO hubot-redis-brain: Data for hubot brain retrieved from Redis
[Wed Jul 29 2015 16:52:45 GMT+0000 (UTC)] INFO Loading commands....
[Wed Jul 29 2015 16:54:45 GMT+0000 (UTC)] INFO Loading commands....
...
(note exactly 24h interval)
...
[Thu Jul 30 2015 16:48:47 GMT+0000 (UTC)] INFO Loading commands....
[Thu Jul 30 2015 16:50:47 GMT+0000 (UTC)] INFO Loading commands....
[Thu Jul 30 2015 16:50:47 GMT+0000 (UTC)] ERROR Failed to retrieve commands: {
    "faultstring": "Unauthorized"
}
[Thu Jul 30 2015 16:52:47 GMT+0000 (UTC)] INFO Loading commands....
[Thu Jul 30 2015 16:52:47 GMT+0000 (UTC)] ERROR Failed to retrieve commands: {
    "faultstring": "Unauthorized"
}

Seems something related to expired tokens,
because after restarting hubot it returns back to normal.

@pixelrebel
Copy link

I receive this error from the get-go of a hubot start.

[Thu Aug 27 2015 16:03:04 GMT-0700 (PDT)] INFO Loading commands....
[Thu Aug 27 2015 16:03:04 GMT-0700 (PDT)] ERROR Failed to retrieve commands from "http://localhost:9101": {
    "faultstring": "Unauthorized"
}

Also tried sudo st2ctl restart with no luck.

@jfryman
Copy link
Contributor

jfryman commented Aug 28, 2015

@pixelrebel Is the username/password that you've passed to Hubot is valid and works via either the CLI or WebUI?

@pixelrebel
Copy link

@jfryman Oops. I didn't do that step, in the past I had auth disabled. How to I pass the credentials to hubot? Can I set an environment variable in hubot.conf? What's a secure method?

@jfryman
Copy link
Contributor

jfryman commented Aug 28, 2015

The best way to sent environment variables is either in the process supervisor that you are using to manage Hubot, or the entry script (bin/hubot). In there, you'll need to set a few env vars (see https://github.com/stackstorm/hubot-stackstorm#plugin-environment-variable-options) and you'll be good to go!

@Kami
Copy link
Member

Kami commented Oct 12, 2015

It looks like this is the same issue as #45.

I will make sure this "limitation" gets noted in the readme for now.

@emedvedev
Copy link
Contributor

This one was fixed some time ago.

@ghost
Copy link

ghost commented Dec 16, 2019

Why would I receive this error using just the Stack Storm in a Docker container and following the quick tutorial, I have logged in at the web interface and in the CLI...?

@blag
Copy link
Contributor

blag commented Dec 18, 2019

@sphinxs Can you point me to the quick tutorial you used? There are a few "quick tutorials" of StackStorm around.

If you are running ST2 as one-microservice-per-container, then I suspect that your st2chatops container is not configured properly. Check the ST2_API_KEY environment variable in the container and make sure it is a valid API key for the ST2 API, or check that the ST2_API_KEY in /opt/stackstorm/chatops/st2chatops.env is set to a valid value.

If you are running all ST2 microservices in a single container, then check that the st2chatops microservice is configured correctly in /opt/stackstorm/chatops/st2chatops.env.

@ghost
Copy link

ghost commented Dec 18, 2019

The tutorial was this one. I'm running as a single container.

Here's the log about the key you have informed me @blag :

root@228b8cf12449:/# cat /opt/stackstorm/chatops/st2chatops.env | grep ST2_API_KEY
export ST2_API_KEY="${ST2_API_KEY}"
# (Uncomment ST2_AUTH_URL, ST2_AUTH_USERNAME, ST2_AUTH_PASSWORD and comment out ST2_API_KEY)

I searched the key in the documentation and found this, I'm confused, if they are at the same host I still need to set the key just like KEY=VALUE?!?

@ghost
Copy link

ghost commented Dec 18, 2019

I get how it works watching the StackStorm 101 (v0.12)

@blag
Copy link
Contributor

blag commented Dec 21, 2019

Okay, just keep in mind that that tutorial is over four years old at this point, and is running StackStorm 0.12. The last released version of StackStorm was 3.1, so there's been quite a few changes since then and things may not work the same way. And hubot-stackstorm in particular has seen some huge refactoring lately.

I don't really know how one would (properly) run Atom in a container, and I'm pretty sure that would cause further issues for you. Either way, it's outside the scope of this issue, but if you really would like to find the answer, you can try asking in Docker's own community.

Running StackStorm in Docker is difficult, so for pack development, I would highly recommend running it in a Vagrant container using this repository:
https://github.com/StackStorm/st2vagrant

That will remove one large layer of configuration complication (eg: Docker) for you, just make sure you read and follow the README for that repository. It will install and configure ST2 for you, although you will need to add your Slack token to /opt/stackstorm/chatops/st2chatops.env and restart chatops (st2ctl restart-component st2chatops). Running ST2 in a VM is really how ST2 was designed to be run, even though we have been working towards running it in Docker and Kubernetes, so the more you stick with that the fewer confusing issues you will have.

The README for st2vagrant also has directions for how to configure a shared volume between the host and the ST2 VM, so you can modify the pack on your host (in Atom!) and test it out in the VM.

Our documentation on packs themselves is here:
https://docs.stackstorm.com/packs.html

And our guide to creating and contributing packs is here:
https://docs.stackstorm.com/reference/packs.html

You can also search for free, pre-existing packs on StackStorm Exchange:
https://exchange.stackstorm.org

Hopefully some of those are useful to you so you don't have to reinvent any wheels. 😄

Lastly, instead of necromancing a long-resolved GitHub issue, you may find better support by asking in our forum, or especially in our Slack community. If you need more individualized support, you can contact Extreme Sales by filling out the form on this page:
https://www.extremenetworks.com/contact-sales

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

6 participants