mmangino / facebooker2

A simple facebook connect library for ruby
MIT License
311 stars 93 forks source link

Problems when deploying with Rubber #54

Closed ReLrO closed 12 years ago

ReLrO commented 13 years ago

I have implemented Facebooker2 on my project and it works perfectly on my development server as well on a local production server. After deploying the project to Amazon EC2 using Rubber, the application fails when trying to connect with facebook. I am getting this error: NoMethodError (undefined method `fetch' for nil:NilClass): which occurs when I am trying to fetch the current_facebook_user information. Its seems as if the current_facebook_user is not populated with the returned values from Facebook and that it is remaining nil. Again it is working perfectly on dev env and local production env. Am I missing something? Please help.

mmangino commented 13 years ago

Is your facebooker.yml file configured correctly and your server domain is correctly set on Facebook? This type of question is best asks on the google group.

Mike

On Jul 25, 2011, at 2:03 PM, ReLrO wrote:

I have implemented Facebooker2 on my project and it works perfectly on my development server as well on a local production server. After deploying the project to Amazon EC2 using Rubber, the application fails when trying to connect with facebook. I am getting this error: NoMethodError (undefined method `fetch' for nil:NilClass): which occurs when I am trying to fetch the current_facebook_user information. Its seems as if the current_facebook_user is not populated with the returned values from Facebook and that it is remaining nil. Again it is working perfectly on dev env and local production env. Am I missing something? Please help.

Reply to this email directly or view it on GitHub: https://github.com/mmangino/facebooker2/issues/54

Mike Mangino http://www.elevatedrails.com

ReLrO commented 13 years ago

Sorry I didn't know... anyway this is my facebook.yml: production: app_id: [my api key] secret: [my secret] api_key: [my api key again]

and on Facebook it is set to: http://mydomain.com/

and in my canvas (which I am using): http://mydomain.com/canvas/ (this routes to the canvas auth in my app)

mmangino commented 13 years ago

The only other thing to check is the auth domain, but that looks right. I would make sure you're getting all the facebook parameters you expect. Without actual info, code and logs I'm just guessing.

Mike

On Jul 25, 2011, at 2:22 PM, ReLrO wrote:

Sorry I didn't know... anyway this is my facebook.yml: production: app_id: [my api key] secret: [my secret] api_key: [my api key again]

and on Facebook it is set to: http://mydomain.com/

and in my canvas (which I am using): http://mydomain.com/canvas/ (this routes to the canvas auth in my app)

Reply to this email directly or view it on GitHub: https://github.com/mmangino/facebooker2/issues/54#issuecomment-1647835

Mike Mangino http://www.elevatedrails.com

ReLrO commented 13 years ago

I'll keep on trying. Thanks

ReLrO commented 13 years ago

Started GET "/canvas/facebook?code=AQCAmqL3HVas4gaaZ-7vWYg6xUR8NU4CPPV11sPEzweqDojdNcgXYZ7fdNYDb8fPdOqizYHc6qjBnIElVYHATL65f_sOhMfd8YQqfsb8rcRdCxzb1yhAJUrVeGc6fO2qCkVl42Kq2rhYDxuVsQldGRXtEChgyU5ePHNXEQKgl4SX1d61KFJ2p6d6ulWZzPyFZIU" for [ip] at 2011-07-25 15:42:46 -0400 Processing by SessionsController#facebook as HTML Parameters: {"code"=>"AQCAmqL3HVas4gaaZ-7vWYg6xUR8NU4CPPV11sPEzweqDojdNcgXYZ7fdNYDb8fPdOqizYHc6qjBnIElVYHATL65f_sOhMfd8YQqfsb8rcRdCxzb1yhAJUrVeGc6fO2qCkVl42Kq2rhYDxuVsQldGRXtEChgyU5ePHNXEQKgl4SX1d61KFJ2p6d6ulWZzPyFZIU"} Completed in 1ms

NoMethodError (undefined method fetch' for nil:NilClass): app/controllers/sessions_controller.rb:19:inget_user_info' app/controllers/sessions_controller.rb:12:in `facebook'

That what the log shows...

mmangino commented 13 years ago

Is the code parameter handled by facebooker? I would read through the code and see what is happening and trace through where the process bails out.

Mike

On Jul 25, 2011, at 3:47 PM, ReLrO wrote:

Started GET "/canvas/facebook?code=AQCAmqL3HVas4gaaZ-7vWYg6xUR8NU4CPPV11sPEzweqDojdNcgXYZ7fdNYDb8fPdOqizYHc6qjBnIElVYHATL65f_sOhMfd8YQqfsb8rcRdCxzb1yhAJUrVeGc6fO2qCkVl42Kq2rhYDxuVsQldGRXtEChgyU5ePHNXEQKgl4SX1d61KFJ2p6d6ulWZzPyFZIU" for [ip] at 2011-07-25 15:42:46 -0400 Processing by SessionsController#facebook as HTML Parameters: {"code"=>"AQCAmqL3HVas4gaaZ-7vWYg6xUR8NU4CPPV11sPEzweqDojdNcgXYZ7fdNYDb8fPdOqizYHc6qjBnIElVYHATL65f_sOhMfd8YQqfsb8rcRdCxzb1yhAJUrVeGc6fO2qCkVl42Kq2rhYDxuVsQldGRXtEChgyU5ePHNXEQKgl4SX1d61KFJ2p6d6ulWZzPyFZIU"} Completed in 1ms

NoMethodError (undefined method fetch' for nil:NilClass): app/controllers/sessions_controller.rb:19:inget_user_info' app/controllers/sessions_controller.rb:12:in `facebook'

That what the log shows...

Reply to this email directly or view it on GitHub: https://github.com/mmangino/facebooker2/issues/54#issuecomment-1648511

Mike Mangino http://www.elevatedrails.com

ReLrO commented 13 years ago

I have a before_filter which makes sure the app is installed. This is the code: before_filter :ensure_application_is_installed, :only => [:canvas]

helper_method :current_facebook_user, :logged_in? before_filter :set_p3p_header_for_third_party_cookies

def ensure_application_is_installed if logged_in? true else top_redirect_to authentication_url false end end

 def authentication_url
   return_url = 'http://apps.facebook.com/' + 'appname' + '/facebook'
   Mogli::Authenticator.new(Facebooker2.app_id, Facebooker2.secret, return_url).authorize_url
 end

 def top_redirect_to(path)
   path = top_url(path) unless path.start_with?('http')
   render :text => "<html><head><script>top.location.href = '#{path}';</script></head><body></body></html>"
 end

 def top_url(path)
   Settings.facebook_apps_url + '/' + 'appname' + '/facebook'
 end

I used the code of another github repository...

ReLrO commented 13 years ago

As I mentioned. This work in local machine perfectly.

mmangino commented 13 years ago

You'll have to trace the facebooker code and see where it goes wrong. I'm not doing any active Facebook development and I have a few deadlines coming up, so I don't have the chance to look at this. I'm happy to take patches that fix the problem once you've found it.

Mike

On Jul 25, 2011, at 3:54 PM, ReLrO wrote:

I have a before_filter which makes sure the app is installed. This is the code: before_filter :ensure_application_is_installed, :only => [:canvas]

helper_method :current_facebook_user, :logged_in? before_filter :set_p3p_header_for_third_party_cookies

def ensure_application_is_installed if logged_in? true else top_redirect_to authentication_url false end end

def authentication_url
  return_url = 'http://apps.facebook.com/' + 'appname' + '/facebook'
  Mogli::Authenticator.new(Facebooker2.app_id, Facebooker2.secret, return_url).authorize_url
end

def top_redirect_to(path)
  path = top_url(path) unless path.start_with?('http')
  render :text => "<html><head><script>top.location.href = '#{path}';</script></head><body></body></html>"
end

def top_url(path)
  Settings.facebook_apps_url + '/' + 'appname' + '/facebook'
end

I used the code of another github repository...

Reply to this email directly or view it on GitHub: https://github.com/mmangino/facebooker2/issues/54#issuecomment-1648567

Mike Mangino http://www.elevatedrails.com

ReLrO commented 13 years ago

Ok. Thanks.

ReLrO commented 13 years ago

BTW.. just to put me on the right direction. could it have anything to do with Mogli? Is there a chance I have to manually configure it?

mmangino commented 13 years ago

I wouldn't think so, but who knows. Facebook changes the rules so often I have a hard time keeping them straight.

Mike

On Jul 25, 2011, at 4:27 PM, ReLrO wrote:

BTW.. just to put me on the right direction. could it have anything to do with Mogli? Is there a chance I have to manually configure it?

Reply to this email directly or view it on GitHub: https://github.com/mmangino/facebooker2/issues/54#issuecomment-1648860

Mike Mangino http://www.elevatedrails.com

ReLrO commented 13 years ago

ok.. :) what's strange is that it does work on local machine with app set to localhost:3000 i'll keep trying.. Thanks!

ReLrO commented 13 years ago

Think I found the problem. the get request has the server local ip in it instead of the external ip.. when running on local host that ip is the same. Only thing now is to figure out how to change it...