Topic: How to get access_token from Stripe within Rails app

Hello,

I've been able to setup stripe for payment processing and am now trying to set it up so users can can process payments with Stripe Connect.

I'm able to get the authorization_code but I'm not able to get the access_token.
References:
https://stripe.com/docs/connect/reference
Using this Stripe Connect gem:
https://github.com/isaacsanders/omniauth-stripe-connect

Clicking a link pointing to the following URL appears to properly redirect to the stripe sign / authorize screen:

localhost:3000/auth/stripe_connect?response_type=code&client_id=___XXXAPPID___&scope=read_write 

Then the user gets redirected back to my app.

It's unclear to me what is the next step?  They get directed back to my app with the authorization_code. I want to take that code and make another request to get the access_token.

I've tried passing the proper parameteres to localhost:3000/auth/stripe_connect
According to the omniauth-stripe-connect documentation you can just post to that url and it will go to Stripe. This works for getting the authorization_code but seems to time out when attempting to use Net::HTTP.post_form to make a request.

And pointing the Net::HTTP.post_form request to stripe's token url, "https://connect.stripe.com/oauth/token"
returns the error :

  EOFError in UsersController#set_gateway_details

  end of file reached

begining test code...
The controller checks of there is a 'code' param and if so, attempts to get the token..

#app/model/user.rb

  def get_stripe_token_oauth(authorization_code)
    stripe_key ='____SECRET_KEY____'
 
    url = "https://connect.stripe.com/oauth/token"
    form_data = {
      'client_secret' => stripe_key,
      'grant_type'    => 'authorization_code',
      'code'          => authorization_code
    }
   results = Net::HTTP.post_form(URI.parse(url), form_data)

    logger.info " #{results.inspect} Test Stripe Results"

  end

So anyway I must be misunderstanding something with how to properly get the OAuth token / HTTP.post_form...

Is there any more information about setting up OAuth / rails and stripe somewhere? 

Thanks

Last edited by internets (2013-05-27 19:27:42)