OmniAuth Strategies Facebook NoAuthorizationCodeError (must pass either a `code` parameter or a signed request (via `signed_request` parameter):

I recently encountered this error when also using the FB JS SDK with omniauth-facebook. I fixed it by sending the signed_request parameter with the GET as shown below: $(document).bind(“fb.loaded”, function() { FB.getLoginStatus(function(response) { console.log(‘FB STATUS: ‘ + response.status); if(response.status == “connected”) { console.log(“FB AUTHED”); location.href=”https://stackoverflow.com/auth/facebook/callback?” + $.param({ signed_request: response.authResponse.signedRequest }) }); } }); }); The … Read more

Refresh token using Omniauth-oauth2 in Rails application

Omniauth doesn’t offer this functionality out of the box so i used the previous answer and another SO answer to write the code in my model User.rb def refresh_token_if_expired if token_expired? response = RestClient.post “#{ENV[‘DOMAIN’]}oauth2/token”, :grant_type => ‘refresh_token’, :refresh_token => self.refresh_token, :client_id => ENV[‘APP_ID’], :client_secret => ENV[‘APP_SECRET’] refreshhash = JSON.parse(response.body) token_will_change! expiresat_will_change! self.token = refreshhash[‘access_token’] … Read more

Setting Environment Variables in Rails 3 (Devise + Omniauth)

You could take a look at the comments: You can either set environment variables directly on the shell where you are starting your server: FACEBOOK_APP_ID=12345 FACEBOOK_SECRET=abcdef rails server Or (rather hacky), you could set them in your config/environments/development.rb: ENV[‘FACEBOOK_APP_ID’] = “12345”; ENV[‘FACEBOOK_SECRET’] = “abcdef”; An alternative way However I would do neither. I would create … Read more

Omniauth Facebook Error – Faraday::Error::ConnectionFailed

I’ve fixed this on Mac OS X Lion 10.7.4 with this solution: $ rvm remove 1.9.3 (or whatever version of ruby you are using) $ rvm pkg install openssl $ rvm install 1.9.3 –with-openssl-dir=$rvm_path/usr after this you will need to download the missing cacert.pem file: $ cd $rvm_path/usr/ssl $ sudo curl -O http://curl.haxx.se/ca/cacert.pem $ sudo … Read more

OpenSSL::SSL::SSLError on Heroku [duplicate]

After some searching here is what I found: If you’re using Ruby to open connections to an external server over https, eg. the Facebook Graph API, you may run into the following error: OpenSSL::SSL::SSLError:SSL_connectreturned=1errno=0state=SSLv3readservercertificateB:certificateverifyfailed This error is due to Ruby not being able to find the certification authority certificates (CA Certs) used to verify the … Read more

Turn omniauth facebook login into a popup

Sure, you can easily. In your view: =link_to “Log in with Facebook”, omniauth_authorize_path(:user, :facebook), :class => “popup”, :”data-width” => 600, :”data-height” => 400 In your application.js: function popupCenter(url, width, height, name) { var left = (screen.width/2)-(width/2); var top = (screen.height/2)-(height/2); return window.open(url, name, “menubar=no,toolbar=no,status=no,width=”+width+”,height=”+height+”,toolbar=no,left=”+left+”,top=”+top); } $(“a.popup”).click(function(e) { popupCenter($(this).attr(“href”), $(this).attr(“data-width”), $(this).attr(“data-height”), “authPopup”); e.stopPropagation(); return false; }); … Read more

OmniAuth & Facebook: certificate verify failed [duplicate]

The real problem is that Faraday (which Omniauth/Oauth use for their HTTP calls) is not wasn’t setting the ca_path variable for OpenSSL. At least on Ubuntu, most root certs are stored in “/etc/ssl/certs”. Since Faraday isn’t wasn’t setting this variable (and currently does not have a method to do so), OpenSSL isn’t wasn’t finding the … Read more