Stripe Connect - POST

Hi! 

I am trying to get Stripe Connect working. Long story short, I have setup stripe accounts, and I am trying to get a token by submitting a POST request. I keep getting the following error: 

RESPONSE: {
  “error”: “invalid_request”,
  “error_description”: “No grant type specified”
}

I know this might be a Stripe issue, but after doing research it might be a URL encode issue on the corona side. If it is a URL encode issue, what should my code look like? 

I am pulling my hair out on this and would love some advice!

Here is my code:

=====================================================

api_key = “sk_test_4tLUxxxxxx”   – I am using the real one

    function networkListener( event )

             if ( event.isError ) then

            print( “Network error!” )

        else

            print( "RESPONSE: "…event.response )

            end

    end

    

    local key = {[“Bearer”] = api_key}

    

    local headers = { 

        [“Authorization”] ="Bearer "…api_key,

        [“Content-Type”] = “application/x-www-form-urlencoded”,

        [“client_secret”] = “sk_test_xxxx”,                                         – I am using the real one

        [“code”] = “ac_xxxx”,                                                             – I am using the real one

        [“grant_type”] = “authorization_code”

    }

    

    

    local params = {}

    params.headers = headers

    

    local naw = network.request(“https://connect.stripe.com/oauth/token”, “POST”, networkListener, params)

    

    print(naw)

======================

As a side note, here are the instructions from Stripe: (https://stripe.com/docs/connect/standalone-accounts#sample-code)

Using the code parameter, you should make a POST request to our access_token_url endpoint (also see thesample-code below for non-curl examples):

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

Thanks!

Are you building your own Stripe connectivity or are you using the free Stripe plugin contributed by Jason Schroeder?

I am using Jason’s plugin which works great, but I need to implement Stripe Connect which the plugin does not support.

Hi David,

I’ll look into this and maybe consider expanding the plugin. But give me some time, I’m a bit swamped lately. I’ll chime back in here when I have anything to report. :grinning:

Your a champion! No problem at all.

FYI - I contacted stripe and the problem had something to do with the way I coded the params.header and params.body. I have now successfully received the response from Stripe that I was hoping for. My next step is to try and successfully make a charge to the connected account and receive my commission fee. 

Although Stripe is fantastic and works really well, they really don’t document their API that well. Thanks for all your hard work though, much appreciated! Will keep you posted about my progress.

Are you building your own Stripe connectivity or are you using the free Stripe plugin contributed by Jason Schroeder?

I am using Jason’s plugin which works great, but I need to implement Stripe Connect which the plugin does not support.

Hi David,

I’ll look into this and maybe consider expanding the plugin. But give me some time, I’m a bit swamped lately. I’ll chime back in here when I have anything to report. :grinning:

Your a champion! No problem at all.

FYI - I contacted stripe and the problem had something to do with the way I coded the params.header and params.body. I have now successfully received the response from Stripe that I was hoping for. My next step is to try and successfully make a charge to the connected account and receive my commission fee. 

Although Stripe is fantastic and works really well, they really don’t document their API that well. Thanks for all your hard work though, much appreciated! Will keep you posted about my progress.