stripe-cli icon indicating copy to clipboard operation
stripe-cli copied to clipboard

Configuration in .env file

Open mikeslattery opened this issue 4 years ago • 2 comments

Problem

What are you trying to do?

Run stripe cli in a project directory and use that project's current local configuration file, .env. Many other development cli tools I use do this by default (node, docker-compose, various IDE plugins, hasura, netlify)

This would provide convenience, consistency (with other similar cli tools), and a single location for sensitive values for a local project.

As a workaround, I put this bash in my .zshrc:

stripe() {
  if [ -f .env ]; then
    source .env
    export STRIPE_API_KEY
  fi
  command stripe "$@"
}

Feature

What would help you accomplish your original task

The stripe-cli would read the .env file for the stripe API key, if it exists, from the current working directory, overriding the api key value in ~/.config/stripe/config.toml.

Examples

Any example interaction you expect

.env file in the the current working directory contains:

STRIPE_API_KEY=sk_test_09f4jr9843j409qhdfasd89

Running any stripe sub-command from the same directory uses the api key.

For security, I'd suggest to enforce the file not have global visibility (600 on Mac/Linux/WSL)

mikeslattery avatar May 04 '21 12:05 mikeslattery

Thanks for the suggestion! This is a good idea, will see if we can do this.

tomer-stripe avatar May 05 '21 14:05 tomer-stripe

I'd like to add that STRIPE_SECRET_KEY would be a better choice than STRIPE_API_KEY. The former is what's used by other tools and APIs.

mikeslattery avatar Jul 12 '22 21:07 mikeslattery