I am trying to send the proper request to Stripe to process my connect tokens, and I can't get it right.

This is the curl request they give as an example:

curl -X POST https://connect.stripe.com/oauth/token \
  -d client_secret=sk_test_******************** \
  -d code=AUTHORIZATION_CODE \
  -d grant_type=authorization_code

This is my attempt with node-oath:

var OAuth2 = OAuth.OAuth2;    
  var client_id = 'ca_******************';
  var secret = 'sk_test_*****************';
  var oauth2 = new OAuth2(client_id,
    secret, 
    'https://connect.stripe.com/', 
    null,
    'oauth/token', 
    null);
  oauth2.getOAuthAccessToken(
    {'code':'ac_******************'},
    {'grant_type':'authorization_code'},
    function (e, access_token, refresh_token, results){
    console.log('bearer: ',e);
  });

I am able to get a response but it is always:

{ statusCode: 400,
  data: '{\n  "error": "invalid_grant",\n  "error_description": "Authorization code does not exist: "\n}' }

I know my keys are right, I just think I am putting them in the wrong places. There is almost no documentation on the node-oauth module so I'm not sure what the arguments are supposed to be.

I ran into the same problem...

The problem was solved by removing the parameter definition "{'code':'ac_**************'}" and just passing in the code "'ac_**************'"...

oauth2.getOAuthAccessToken(
    'ac_******************',
    {'grant_type':'authorization_code'},
    function (e, access_token, refresh_token, results){
    console.log('bearer: ',e);
  });

The auth code passed from stripe to your callback URL is case sensitive, check that your server is not forcing to lowercase.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.