I've been messing around with Rails and Facebook Registration over the weekend. I finally got it working, but it literally took me all weekend. I need to document this because I'll forget what I did by tomorrow morning, and don't want to do it again. Also, figured this might help other's with the same problems.
First, my local config:
I had three major issues getting this working. The first was trivial, the second was horrible, the third was my bad.
Issue 1: Omniauth Authentication on Facebook.
First, my local config:
- Mac running Mountain Lion
- Ruby 1.9.3
- My gem file:
source 'https://rubygems.org'In general, I followed the instructions posted here, posted at the OmniAuth Github.
gem 'rails', '3.2.8'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'devise'
gem 'omniauth'
gem 'omniauth-facebook'
I had three major issues getting this working. The first was trivial, the second was horrible, the third was my bad.
Issue 1: Omniauth Authentication on Facebook.
- The issue is described well here, on Stackoverflow.
- Error Message: Invalid redirect_uri: Given URL is not allowed by the Application configuration.
- What they didn't describe (and actually Teamtreehouse.com describes it the same way), is that your "Site URL" on your Facebook config page isn't http://localhost:3000. It should be http://0.0.0.0:3000/ . I messed with this for an hour.
Issue 2: Omniauth and Facebook certificate verify fail.
- The error message: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
- The Omniauth instructions above actually describe the issue well (and there's an extensive trail on this too). It didn't address my issue which was that I didn't have any root certification authorities (CA)
- The solve was on a separate Stackoverflow question, here.
Issue 3: "Could not authorize you from Facebook because "Csrf detected".'"$ 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 mv cacert.pem cert.pem
- Solve was described here.
- Addressed by just deleting the Omniauth config file.
1 comment:
Fantastic site. Heaps of valuable information here. I'm sending it to a few buddies ans additionally partaking in flavorful. What's more, obviously, thank you for your perspiration!
2-Yard Skip
Post a Comment