devMan
devMan

Reputation: 89

access denied when trying to connect to stripe platform account

following the code in the stripe connect documentation, and using a developer test API, the code i use in a node.js server :

app.get("/authorize", function(req, res) {
  // Redirect to Stripe /oauth/authorize endpoint
  res.redirect(AUTHORIZE_URI + "?" + qs.stringify({
    response_type: "code",
    scope: "read_write",
    client_id: CLIENT_ID
  }));
});


app.get("/oauth/callback", function(req, res) {

  var code = req.query.code;

  // Make /oauth/token endpoint POST request
  request.post({
    url: TOKEN_URI,
    form: {
      grant_type: "authorization_code",
      client_id: CLIENT_ID,
      code: code,
      client_secret: API_KEY
    }
  }, function(err, r, body) {

    var accessToken = JSON.parse(body).access_token;

    // Do something with your accessToken

    // For demo"s sake, output in response:
    res.send({ "Your Token": accessToken });

  });
});

I also set the redirect URI in the connect setting in the stripe dashboard,

now when am accessing the /authorize it redirect me to the connect.stripe and ask me either to connect or create a stripe accopunt ( with a banner on top say Development Mode: You're currently using this application in development mode. skip from ..... ), so if I click the connect button after login, am getting access denied error and getting no authorization code, or if skip the form I get the access token,

so is this due to the development mode? if I change to production I will get the success token and user id after connect ? or do I miss something?

Upvotes: 0

Views: 1224

Answers (1)

JimM
JimM

Reputation: 11

If you are doing this in localhost, your request never leaves your computer and doesn't get to stripe to make the request.

use https://ngrok.com/

one you have it run it with $ ngrok http [your localhost number]

for example if you are using localhost:8080 you would run

$ ngrok http 8080

and replace your redirect_uri with a https option, that should complete the call back, but this changes everytime you use ngrok, so it can be a bit finicky if you are turning it on and off quite a lot.

Upvotes: 1

Related Questions