Open menan opened 11 years ago
A stacktrace would be helpful. It sounds like an authorization code is being used multiple times. Make sure you exchange the code for a token once and then store the token.
It's happening every time I call the current_facebook_user object. I am not storing any session variables manually. Should I?
BTW: I am using facebooker2. I guess I am suppose to post this in there. I just noticed it, My bad.
Here is my stack trace, there is not a lot:
app/controllers/application_controller.rb:31:in `current_user'
app/controllers/songs_controller.rb:18:in `index'
Here is my current_user method:
def current_user
@me = User.find_by_facebook_id(current_facebook_user.id) if current_facebook_user
end
Thank you
That seems awfully incomplete, since the call should be somewhere inside current_facebook_user. Basically, once you use a code, you need to cache the token info and inflate the session yourself.
current_facebook_user is implemented under facebooker2. So, I am not sure how that works. I will take a look. However it looks like an issue with Facebook. Other users are facing similar issues too. According to their december update or something.
It is implemented under facebooker, but getting that stacktrace is still helpful.
Mike
On Dec 8, 2012, at 5:48 PM, Menan Vadivel notifications@github.com wrote:
current_facebook_user is implemented under facebooker2. So, I am not sure how that works. I will take a look. However it looks like an issue with Facebook. Other users are facing similar issues too. According to their december update or something.
— Reply to this email directly or view it on GitHub.
Sorry bro, I am pretty new to rails haha. I thought that was the stack trace. Here is where things are going wrong in facebooker.
/Users/alexandrecarriere/.bundler/ruby/1.8/mogli-b8f68b5d7e44/lib/mogli/client.rb:79:in `raise_error_by_type_and_message'
/Users/alexandrecarriere/.bundler/ruby/1.8/mogli-b8f68b5d7e44/lib/mogli/client.rb:70:in `raise_client_exception'
/Users/alexandrecarriere/.bundler/ruby/1.8/mogli-b8f68b5d7e44/lib/mogli/client.rb:52:in `create_from_code_and_authenticator'
/Users/alexandrecarriere/.bundler/ruby/1.8/facebooker2-504cc261af61/lib/facebooker2/rails/controller.rb:231:in `oauth2_fetch_client_and_user_from_cookie'
/Users/alexandrecarriere/.bundler/ruby/1.8/facebooker2-504cc261af61/lib/facebooker2/rails/controller.rb:221:in `oauth2_fetch_client_and_user'
/Users/alexandrecarriere/.bundler/ruby/1.8/facebooker2-504cc261af61/lib/facebooker2/rails/controller.rb:16:in `current_facebook_user'
app/controllers/application_controller.rb:31:in `current_user'
app/controllers/users_controller.rb:28:in `show'
This means you are using the code passed in from Facebook multiple times. What I've done is to instead have a special URL that the oauth code sends the login to. In there, I get the client information using the following code:
mogli_client = Mogli::Client.create_from_code_and_authenticator(params[:code], authenticator)
facebook_user = Mogli::User.find("me", mogli_client)
session[:facebook_access_token] = mogli_client.access_token
session[:facebook_user_id] = facebook_user.id
The rest of our application then looks for the access token and the user id and uses them to create the facebook user and session.
Mike
On Dec 10, 2012, at 1:08 PM, Menan Vadivel notifications@github.com wrote:
Sorry bro, I am pretty new to rails haha. I thought that was the stack trace. Here is the full trace
/Users/alexandrecarriere/.bundler/ruby/1.8/mogli-b8f68b5d7e44/lib/mogli/client.rb:79:in
raise_error_by_type_and_message' /Users/alexandrecarriere/.bundler/ruby/1.8/mogli-b8f68b5d7e44/lib/mogli/client.rb:70:in
raise_client_exception' /Users/alexandrecarriere/.bundler/ruby/1.8/mogli-b8f68b5d7e44/lib/mogli/client.rb:52:increate_from_code_and_authenticator' /Users/alexandrecarriere/.bundler/ruby/1.8/facebooker2-504cc261af61/lib/facebooker2/rails/controller.rb:231:in
oauth2_fetch_client_and_user_from_cookie' /Users/alexandrecarriere/.bundler/ruby/1.8/facebooker2-504cc261af61/lib/facebooker2/rails/controller.rb:221:inoauth2_fetch_client_and_user' /Users/alexandrecarriere/.bundler/ruby/1.8/facebooker2-504cc261af61/lib/facebooker2/rails/controller.rb:16:in
current_facebook_user' app/controllers/application_controller.rb:31:incurrent_user' app/controllers/users_controller.rb:28:in
show' actionpack (3.2.0) lib/action_controller/metal/implicit_render.rb:4:insend_action' actionpack (3.2.0) lib/action_controller/metal/implicit_render.rb:4:in
send_action' actionpack (3.2.0) lib/abstract_controller/base.rb:167:inprocess_action' actionpack (3.2.0) lib/action_controller/metal/rendering.rb:10:in
process_action' actionpack (3.2.0) lib/abstract_controller/callbacks.rb:18:inprocess_action' activesupport (3.2.0) lib/active_support/callbacks.rb:436:in
_run477286948process_action1894589059callbacks' activesupport (3.2.0) lib/active_support/callbacks.rb:405:insend' activesupport (3.2.0) lib/active_support/callbacks.rb:405:in
run_callback' activesupport (3.2.0) lib/active_support/callbacks.rb:385:in_run_process_action_callbacks' activesupport (3.2.0) lib/active_support/callbacks.rb:81:in
send' activesupport (3.2.0) lib/active_support/callbacks.rb:81:inrun_callbacks' actionpack (3.2.0) lib/abstract_controller/callbacks.rb:17:in
process_action' actionpack (3.2.0) lib/action_controller/metal/rescue.rb:29:inprocess_action' actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:30:in
process_action' activesupport (3.2.0) lib/active_support/notifications.rb:123:ininstrument' activesupport (3.2.0) lib/active_support/notifications/instrumenter.rb:20:in
instrument' activesupport (3.2.0) lib/active_support/notifications.rb:123:ininstrument' actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:29:in
process_action' actionpack (3.2.0) lib/action_controller/metal/params_wrapper.rb:205:inprocess_action' activerecord (3.2.0) lib/active_record/railties/controller_runtime.rb:18:in
process_action' newrelic_rpm (3.5.0.1) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:34:inprocess_action' newrelic_rpm (3.5.0.1) lib/new_relic/agent/instrumentation/controller_instrumentation.rb:268:in
perform_action_with_newrelic_trace' newrelic_rpm (3.5.0.1) lib/new_relic/agent/method_tracer.rb:242:intrace_execution_scoped' newrelic_rpm (3.5.0.1) lib/new_relic/agent/instrumentation/controller_instrumentation.rb:263:in
perform_action_with_newrelic_trace' newrelic_rpm (3.5.0.1) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:33:inprocess_action' actionpack (3.2.0) lib/abstract_controller/base.rb:121:in
process' actionpack (3.2.0) lib/abstract_controller/rendering.rb:45:inprocess' actionpack (3.2.0) lib/action_controller/metal.rb:203:in
dispatch' actionpack (3.2.0) lib/action_controller/metal/rack_delegation.rb:14:indispatch' actionpack (3.2.0) lib/action_controller/metal.rb:246:in
action' actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:66:incall' actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:66:in
dispatch' actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:30:incall' journey (1.0.4) lib/journey/router.rb:68:in
call' journey (1.0.4) lib/journey/router.rb:56:ineach' journey (1.0.4) lib/journey/router.rb:56:in
call' actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:570:incall' omniauth (1.1.1) lib/omniauth/strategy.rb:177:in
call!' omniauth (1.1.1) lib/omniauth/strategy.rb:157:incall' omniauth (1.1.1) lib/omniauth/builder.rb:48:in
call' newrelic_rpm (3.5.0.1) lib/new_relic/rack/error_collector.rb:8:incall' newrelic_rpm (3.5.0.1) lib/new_relic/rack/browser_monitoring.rb:12:in
call' newrelic_rpm (3.5.0.1) lib/new_relic/rack/developer_mode.rb:24:incall' actionpack (3.2.0) lib/action_dispatch/middleware/best_standards_support.rb:17:in
call' rack (1.4.1) lib/rack/etag.rb:23:incall' rack (1.4.1) lib/rack/conditionalget.rb:25:in
call' actionpack (3.2.0) lib/action_dispatch/middleware/head.rb:14:incall' remotipart (1.0.2) lib/remotipart/middleware.rb:30:in
call' actionpack (3.2.0) lib/action_dispatch/middleware/params_parser.rb:21:incall' actionpack (3.2.0) lib/action_dispatch/middleware/flash.rb:242:in
call' rack (1.4.1) lib/rack/session/abstract/id.rb:205:incontext' rack (1.4.1) lib/rack/session/abstract/id.rb:200:in
call' actionpack (3.2.0) lib/action_dispatch/middleware/cookies.rb:338:incall' activerecord (3.2.0) lib/active_record/query_cache.rb:64:in
call' activerecord (3.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:incall' actionpack (3.2.0) lib/action_dispatch/middleware/callbacks.rb:28:in
call' activesupport (3.2.0) lib/active_support/callbacks.rb:405:in `_run1999871681call4callbacks' activesupport (3.2.0) lib/active_support/callbacks.rb:405:insend' activesupport (3.2.0) lib/active_support/callbacks.rb:405:in
run_callback' activesupport (3.2.0) lib/active_support/callbacks.rb:385:in_run_call_callbacks' activesupport (3.2.0) lib/active_support/callbacks.rb:81:in
send' activesupport (3.2.0) lib/active_support/callbacks.rb:81:inrun_callbacks' actionpack (3.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in
call' actionpack (3.2.0) lib/action_dispatch/middleware/reloader.rb:65:incall' actionpack (3.2.0) lib/action_dispatch/middleware/remote_ip.rb:31:in
call' actionpack (3.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:16:incall' actionpack (3.2.0) lib/action_dispatch/middleware/show_exceptions.rb:56:in
call' railties (3.2.0) lib/rails/rack/logger.rb:26:incall_app' railties (3.2.0) lib/rails/rack/logger.rb:16:in
call' actionpack (3.2.0) lib/action_dispatch/middleware/request_id.rb:22:incall' rack (1.4.1) lib/rack/methodoverride.rb:21:in
call' rack (1.4.1) lib/rack/runtime.rb:17:incall' activesupport (3.2.0) lib/active_support/cache/strategy/local_cache.rb:72:in
call' rack (1.4.1) lib/rack/lock.rb:15:incall' actionpack (3.2.0) lib/action_dispatch/middleware/static.rb:53:in
call' railties (3.2.0) lib/rails/engine.rb:479:incall' railties (3.2.0) lib/rails/application.rb:220:in
call' rack (1.4.1) lib/rack/content_length.rb:14:incall' railties (3.2.0) lib/rails/rack/log_tailer.rb:14:in
call' rack (1.4.1) lib/rack/handler/webrick.rb:59:inservice' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in
service' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:65:inrun' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:173:in
start_thread' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:instart' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in
start_thread' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:95:instart' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in
each' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:instart' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:23:in
start' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:82:instart' rack (1.4.1) lib/rack/handler/webrick.rb:13:in
run' rack (1.4.1) lib/rack/server.rb:265:instart' railties (3.2.0) lib/rails/commands/server.rb:70:in
start' railties (3.2.0) lib/rails/commands.rb:55 railties (3.2.0) lib/rails/commands.rb:50:intap' railties (3.2.0) lib/rails/commands.rb:50 script/rails:6:in
require' script/rails:6 Reply to this email directly or view it on GitHub.
I've got it to work with the custom current_facebook_user method using the session token like you said. You might want to fix the facebooker though. It seems broken. Thanks for your help.
I don't do anything with Facebook anymore, so I'd rather somebody who has a real world test case to send a patch.
Mike
On Dec 10, 2012, at 3:00 PM, Menan Vadivel notifications@github.com wrote:
I've got it to work with the custom current_facebook_user method using the session token like you said. You might want to fix the facebooker though. It seems broken. Thanks for your help.
— Reply to this email directly or view it on GitHub.
Sounds good :) I am not smart enough to fix your code man sorry.
I keep getting this exception for only last couple days. What do you think it could be?
Mogli::Client::OAuthException (This authorization code has been used.)