stripe-cli: listen fails when run non-interactively
Issue
I am trying to run stripe listen non-interactively in one docker container to proxy events to a different docker container, so that I can validate my webhooks in an automated test.
I run:
stripe listen --device-name my-test --api-key sk_test_XXXX
The output is:
your device name has not been configured. Use `stripe configure` to set your device name
but if I then run:
stripe configure
it outputs:
unknown command "configure" for "stripe"
So, the issue is:
- I don’t know what a device is, but according to
stripe listen --helpI should be able to set this with--device-name. The first command should succeed as is. - The error output should not refer to a nonexistent command.
If I populate ~/.config/stripe/config.toml directly instead of using command-line flags, stripe listen works great. (While undocumented, this might be a better idea regardless, because then I don’t need to worry about my API key being in an error message if the command fails.)
Environment
Ubuntu 18.04 running under Docker, Stripe CLI 0.2.3 installed via https://github.com/stripe/stripe-cli/releases/download/v0.2.3/stripe_0.2.3_linux_amd64.deb.
Postscript
stripe listen is great. I’ve been wanting something like this for a long time.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 19 (9 by maintainers)
For those who may stumble upon this in the future, the solution is to create a
.envfile with yourdocker-compose.yml..env file
docker-compose.yml
Then run
$ docker-compose up stripeIf you have
${...}anywhere in your docker-compose file, it looks in.envfor the value.Hope this helps.
Hey @aminnaggar, thanks for the report. I think support for setting the API key via an environment variable is broken in the current version (0.8.0). We will investigate and report back here soon. Sorry for the inconvenience!
UPDATE 2021
For those looking to setup stripe cli webhooks with their docker-compose test environment, here’s my setup:
.env file
docker-compose.yml
Then run
$ docker-compose upTake note that the server service is a node server, accessible at localhost:3000. The stripe service accesses it in the docker-compose network through
server:3000.Lastly, the
-aflag allows us to listen to events triggered from the stripe test environment. You can remove the-aflag if you want to only listen to events triggered locally.Hope this helps.
Hey great work on providing a docker image for this. I’m running into the same issue as @Freezystem before me. I’m tryin to run this non-interactively, and I’m getting
this is my configuration
What am I missing? Cheers
Hey all, closing this issue since it looks like we resolved the underlying issues with the listen command. If you’re still having issues please open a new issue!
For setting
--device-name, there was a bug there that I fixed in version 0.5.4 if you want to give that a shot! Sorry for the delay there@Freezystem Done! https://hub.docker.com/r/stripe/stripe-cli
Also, we’d love to hear about how you’re using the CLI in your CI exactly! If you have a few minutes to send us a message using the form at https://stri.pe/cli-feedback, we’d really appreciate it.
@ob-stripe excellent, works great.
@madeleineth You could create the configuration file manually in your container (it’s read from
${XDG_CONFIG_HOME}/stripe/config.toml, or$HOME/.config/stripe/config.tomlifXDG_CONFIG_HOMEis not set), or you can set the API key and device name via environment variables:STRIPE_SECRET_KEYandSTRIPE_DEVICE_NAMErespectively.Out of curiosity, would you find it helpful if we provided Docker images for the CLI?