0

I'm following this tutorial.

I'm stuck in Step 4:

Step 4: Creating the Login Page Let’s create our sessions controller.

Run the following code in your terminal to create a new sessions controller, and the new, create, and failure actions.

rails generate controller sessions new create failure

When I enter the command above in the terminal I get this error (after adding my Facebook's application App ID and App Secret):

/home/alex/apps/omniauth-tutorial/config/initializers/omniauth.rb:2:in block in <top (required)>': undefined local variable or method d0cdb4fe2489xxxxxxxxxxxxxxxxxxxx' for # (NameError)

(the 'x's are the rest of the numbers).

I'm using Rails 3.1.3 and this is what I have in my Gemfile:

Any suggestions to fix this?

source 'http://rubygems.org'

gem 'rails', '3.1.3'

gem 'omniauth'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem 'omniauth-github'
alexchenco
  • 53,565
  • 76
  • 241
  • 413

1 Answers1

2

You should add quotes to the values app id and secret key

config.omniauth :facebook, "APP_ID", "APP_SECRET"

Try this and restart webrick;it should work

dbKooper
  • 1,035
  • 10
  • 17
  • Thanks I tried that but now I'm getting this error (after all files are generated: `{ "error": { "message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.", "type": "OAuthException" } }` – alexchenco Jan 09 '12 at 12:35
  • The problem might be with your facebook callback settings it should be http://localhost:3000/ – dbKooper Jan 09 '12 at 12:38
  • 1
    here: `Rails.application.config.middleware.use OmniAuth::Builder do provider :facebook, "3430xxxxxxxxxx", "d0cdb4xxxxxxxxxxxxxxxxxxx" end` (the 'x's are the rest of the numbers). Is it because I'm setting this on localhost? – alexchenco Jan 09 '12 at 12:40
  • 1
    your facebook app settings call back url should be "http://localhost:3000/" with the trailing slash – dbKooper Jan 09 '12 at 12:43
  • Have u got it correct? other wise pls check ur routes.rb and your facebook application settings with correct callback url's ;thats where the problem lies – dbKooper Jan 09 '12 at 12:58
  • I got this: `Error App Domain: localhost:3000/ is not a valid domain.` – alexchenco Jan 09 '12 at 15:50