Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This authorization code has been used #128

Open
menan opened this issue Dec 7, 2012 · 10 comments
Open

This authorization code has been used #128

menan opened this issue Dec 7, 2012 · 10 comments

Comments

@menan
Copy link

menan commented Dec 7, 2012

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.)

@mmangino
Copy link
Owner

mmangino commented Dec 7, 2012

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.

@menan
Copy link
Author

menan commented Dec 7, 2012

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

@mmangino
Copy link
Owner

mmangino commented Dec 7, 2012

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.

@menan
Copy link
Author

menan commented Dec 8, 2012

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.

@mmangino
Copy link
Owner

It is implemented under facebooker, but getting that stacktrace is still helpful.

Mike

On Dec 8, 2012, at 5:48 PM, Menan Vadivel [email protected] 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.

@menan
Copy link
Author

menan commented Dec 10, 2012

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'

@mmangino
Copy link
Owner

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 [email protected] 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:inraise_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:inoauth2_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:incurrent_facebook_user'
app/controllers/application_controller.rb:31:in current_user' app/controllers/users_controller.rb:28:inshow'
actionpack (3.2.0) lib/action_controller/metal/implicit_render.rb:4:in send_action' actionpack (3.2.0) lib/action_controller/metal/implicit_render.rb:4:insend_action'
actionpack (3.2.0) lib/abstract_controller/base.rb:167:in process_action' actionpack (3.2.0) lib/action_controller/metal/rendering.rb:10:inprocess_action'
actionpack (3.2.0) lib/abstract_controller/callbacks.rb:18:in process_action' activesupport (3.2.0) lib/active_support/callbacks.rb:436:in_run__477286948__process_action__1894589059__callbacks'
activesupport (3.2.0) lib/active_support/callbacks.rb:405:in send' 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:insend'
activesupport (3.2.0) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (3.2.0) lib/abstract_controller/callbacks.rb:17:inprocess_action'
actionpack (3.2.0) lib/action_controller/metal/rescue.rb:29:in process_action' actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:30:inprocess_action'
activesupport (3.2.0) lib/active_support/notifications.rb:123:in instrument' activesupport (3.2.0) lib/active_support/notifications/instrumenter.rb:20:ininstrument'
activesupport (3.2.0) lib/active_support/notifications.rb:123:in instrument' actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:29:inprocess_action'
actionpack (3.2.0) lib/action_controller/metal/params_wrapper.rb:205:in process_action' activerecord (3.2.0) lib/active_record/railties/controller_runtime.rb:18:inprocess_action'
newrelic_rpm (3.5.0.1) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:34:in process_action' newrelic_rpm (3.5.0.1) lib/new_relic/agent/instrumentation/controller_instrumentation.rb:268:inperform_action_with_newrelic_trace'
newrelic_rpm (3.5.0.1) lib/new_relic/agent/method_tracer.rb:242:in trace_execution_scoped' newrelic_rpm (3.5.0.1) lib/new_relic/agent/instrumentation/controller_instrumentation.rb:263:inperform_action_with_newrelic_trace'
newrelic_rpm (3.5.0.1) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:33:in process_action' actionpack (3.2.0) lib/abstract_controller/base.rb:121:inprocess'
actionpack (3.2.0) lib/abstract_controller/rendering.rb:45:in process' actionpack (3.2.0) lib/action_controller/metal.rb:203:indispatch'
actionpack (3.2.0) lib/action_controller/metal/rack_delegation.rb:14:in dispatch' actionpack (3.2.0) lib/action_controller/metal.rb:246:inaction'
actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:66:in call' actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:66:indispatch'
actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:30:in call' journey (1.0.4) lib/journey/router.rb:68:incall'
journey (1.0.4) lib/journey/router.rb:56:in each' journey (1.0.4) lib/journey/router.rb:56:incall'
actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:570:in call' omniauth (1.1.1) lib/omniauth/strategy.rb:177:incall!'
omniauth (1.1.1) lib/omniauth/strategy.rb:157:in call' omniauth (1.1.1) lib/omniauth/builder.rb:48:incall'
newrelic_rpm (3.5.0.1) lib/new_relic/rack/error_collector.rb:8:in call' newrelic_rpm (3.5.0.1) lib/new_relic/rack/browser_monitoring.rb:12:incall'
newrelic_rpm (3.5.0.1) lib/new_relic/rack/developer_mode.rb:24:in call' actionpack (3.2.0) lib/action_dispatch/middleware/best_standards_support.rb:17:incall'
rack (1.4.1) lib/rack/etag.rb:23:in call' rack (1.4.1) lib/rack/conditionalget.rb:25:incall'
actionpack (3.2.0) lib/action_dispatch/middleware/head.rb:14:in call' remotipart (1.0.2) lib/remotipart/middleware.rb:30:incall'
actionpack (3.2.0) lib/action_dispatch/middleware/params_parser.rb:21:in call' actionpack (3.2.0) lib/action_dispatch/middleware/flash.rb:242:incall'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in context' rack (1.4.1) lib/rack/session/abstract/id.rb:200:incall'
actionpack (3.2.0) lib/action_dispatch/middleware/cookies.rb:338:in call' activerecord (3.2.0) lib/active_record/query_cache.rb:64:incall'
activerecord (3.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in call' actionpack (3.2.0) lib/action_dispatch/middleware/callbacks.rb:28:incall'
activesupport (3.2.0) lib/active_support/callbacks.rb:405:in _run__1999871681__call__4__callbacks' 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.

@menan
Copy link
Author

menan commented Dec 10, 2012

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.

@mmangino
Copy link
Owner

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 [email protected] 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.

@menan
Copy link
Author

menan commented Dec 10, 2012

Sounds good :) I am not smart enough to fix your code man sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants