0

I am trying to integrate stripe connect in my application here is reference url (https://stripe.com/docs/connect/oauth). Here they have specified to post authorization code after user have created account

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

here i have client secret and authorization code but when i do ajax post like below

$.ajax({
      type: "POST",
      dataType:"json",
      url: "https://connect.stripe.com/oauth/token/",
      data: {client_secret:"sk_test_gcpX7F3XXXXXXXXXXXX",code:"ac_43xnkqCpBtNu6ywXXXXXXXXXXX",grant_type:"ac_43xnkqCpBtNu6ywqLXXXXXXXXXXXXXX"},
      success: function(resp) {
        alert(resp);
      }
});

I am getting error like 301 moved permanently, Even I don't now can i do ajax post or is there any way we can do this instead of js

can any one help me in getting user account details using accesstoken.

1 Answer 1

0

First, your request is wrong and you should have

grant_type : "authorization_code"

and not with the auth code you just got from the authorization callbak. The other params are fine.

Although I tried using JS instead of JAVA and I got a CORS error at first, so I then I used

dataType : "jsonp"

But the Stripe's server return a response in HTML format and I got a MiME error. I finally gave up on doing it with javascript and did it from my Backend. Seems like a safer option anyway :)

Strip advise you to use a oAuth2 client library to handle the token generation. It now depends the language your backend is using.

Good Luck !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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