stripe / stripe-cli

A command-line tool for Stripe
https://stripe.com/docs/stripe-cli
Apache License 2.0
1.6k stars 374 forks source link

Login with api key on github actions #1053

Open MKlimentowicz opened 1 year ago

MKlimentowicz commented 1 year ago

I want to forward stripe webhooks to a local address in my automated tests in a github action. Unfortunately the interactive login with api key does not work.

Issue

I get this error Enter your API key: inappropriate ioctl for device when I try to execute this stripe login --interactive --api-key ${{ secrets.STRIPE_TEST_API_KEY }}

Expected Behavior

Successful login

Steps to reproduce

Docs: https://stripe.com/docs/stripe-cli#install (apt)

name: bla bla bla
on:
  push:
    branches: [develop]
jobs:
  my-job:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Install stripe cli
        run: |
          curl -s https://packages.stripe.dev/api/security/keypair/stripe-cli-gpg/public | gpg --dearmor | sudo tee /usr/share/keyrings/stripe.gpg
          echo "deb [signed-by=/usr/share/keyrings/stripe.gpg] https://packages.stripe.dev/stripe-cli-debian-local stable main" | sudo tee -a /etc/apt/sources.list.d/stripe.list
          sudo apt update          
          sudo apt install stripe
          stripe login --interactive --api-key ${{ secrets.STRIPE_TEST_API_KEY }}

Traceback

Enter your API key: inappropriate ioctl for device

Environment

Github Actions - Linux - Ubuntu latest

tomer-stripe commented 1 year ago

Ah @MKlimentowicz the --interactive sadly doesn't work like that but we should fix it. The error you're getting is because --interactive will prompt an input from the terminal itself which actions don't support.

There's a few things you can do to get around this:

Cherchercher commented 6 months ago

Any ideas on passing the --api-key in live mode? Just want to run some integ tests there on every deployment. Tried the above suggestions but doesn't work,

stripe listen --forward-to somelivesite/api/webhook

FATAL Error while authenticating with Stripe: Authorization failed, status=403, body={ "error": { "message": "For security reasons, the Stripe CLI only permits the use of restricted keys when in live mode. To generate restricted keys for use in live mode, use the stripe login command.", "type": "invalid_request_error" } }

I guess meanwhile I'll stick with local testing

Thank you

sametbirol commented 1 month ago

@Cherchercher Have you managed to resolve this issue? It looks like you might need to use the --live flag to ensure that the listener identifies live endpoints correctly. You may find more details in the Stripe CLI documentation: StripeCLI