lundi 17 août 2015

SSL Error/Type Error when authenticating Podio in a Rails app

I'm suck. I'm exploring the Podio API and have been trying to play with the sample Podio Rails app to learn how it works but I'm having a couple issues. (Main question at bottom.) At first I had an SSL Error:

Started POST "/sessions/createfromappauth" for 127.0.0.1 at 2015-08-14 09:37:38 -0700
Connecting to database specified by database.yml
Processing by SessionsController#createfromappauth as HTML
Parameters: {"utf8"=>"✓", "authenticitytoken"=>"xxxxx=", "appid"=>"xxxxx", "app_token"=>"xxxxxx", "commit"=>"Authenticate as app"}
Completed 500 Internal Server Error in 660ms

OpenSSL::SSL::SSLError (SSLconnect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed):
  app/controllers/sessionscontroller.rb:23:in `createfromapp_auth' 

I tried updating my SSL certs on my Mac, then updating all the gems in the Rails app but neither worked. In the end I fixed it by putting the cacert.pem file in my /lib directory.

Unfortunately now I get the error:

Started POST "/sessions/create_from_app_auth" for 127.0.0.1 at 2015-08-17 10:39:38 -0700
Processing by SessionsController#create_from_app_auth as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"xxxx", "app_id"=>"xxxx", "app_token"=>"xxxx", "commit"=>"Authenticate as app"}
Completed 500 Internal Server Error in 273ms

TypeError (no implicit conversion of Pathname into String):
  app/controllers/sessions_controller.rb:23:in `create_from_app_auth' 

I'm using a Mac with

  • Ruby: 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
  • Rails: 3.2.8
  • OpenSSL 1.0.2d 9 Jul 2015

Here's the code from the sessions_controller that's causing the error in question:

def create_from_app_auth
  Podio.setup(
    :api_url => 'https://api.podio.com',
    :api_key => ENV['PODIO_CLIENT_ID'],
    :api_secret => ENV['PODIO_CLIENT_SECRET']
  )

  Podio.client.authenticate_with_app(params[:app_id], params[:app_token])

  session[:podio_access_token] = Podio.client.oauth_token.access_token
  session[:podio_refresh_token] = Podio.client.oauth_token.refresh_token

  redirect_to root_url, :notice => "Signed in!"
end

Any ideas on how to fix either the TypeError or the SSLError so I don't get the TypeError? Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire