Search code examples
stripe-paymentsstripe-apps

How to add redirect uri as localhost in Stripe apps?


I have a Stripe app with an OAuth flow, now if you see this Stripe documentation: https://docs.stripe.com/connect/testing#using-oauth. It mentions "If you use the Test mode link, you can set redirect_uri to localhost.

So that's what I did this is my stripe test mode link: https://marketplace.stripe.com/oauth/v2/channellink*A*****cF****j*****YZg/authorize?client_id=ca_****************Gbs&redirect_uri=http://localhost:3000/api/stripe/install

Now the problem is it gives below error: enter image description here

You will ask if you have added that localhost URL to Stripe manifest.json file, Yes I have tried to add it, but when I try to publish that app it gives me this error:

invalid stripe-app.json:
[
 {
  "uri": "http://localhost:3000/api/stripe/install",
  "errors": [
   "expect valid HTTPS URI. got http://localhost:3000/api/stripe/install"
  ]
 }
]

On the other hand, I have added it to the onboarding options: https://dashboard.stripe.com/test/settings/connect/onboarding-options/oauth

enter image description here


Solution

  • Those docs about OAuth are not applicable to Stripe Apps, only Connect platforms (and are no longer a recommended integration pattern).

    The OAuth docs for Stripe Apps do not discuss using localhost as this is not really applicable. Installing the app via OAuth, even in test mode, must be handle via a public redirect URI.

    https://docs.stripe.com/stripe-apps/api-authentication/oauth#create-install-link

    When developing the app, OAuth is not used. Instead, you enable the App on your own account via preview using the CLI.

    https://docs.stripe.com/stripe-apps/create-app#preview-app