0
votes

I'm trying to add/publish a subscription for real time updates via Graph API Explorer. Here is my requested POST url

https://graph.facebook.com/v2.2/{app_id}/subscriptions/?object=user&fields=friends&verify_token=thisisaverifystring&access_token=my_app_token&callback_url=http://mydomain/auth/facebook/callback/

But I'm getting error response:

{ "error": { "message": "(#2200) callback verification failed: ", "type": "OAuthException", "code": 2200 } }

Also I have defined same callback URL twice in my routes to handle GET as well as POST requests. My API request mentioned above is hitting my callback url but I'm also getting error in server logs

Started GET "/auth/facebook/callback/?hub.mode=subscribe&hub.challenge=246450618&hub.verify_token=thisisaverifystring" for 66.220.158.118 at 2015-02-12 19:24:12 +0530 I, [2015-02-12T19:24:12.530395 #18960] INFO -- omniauth: (facebook) Callback phase initiated. E, [2015-02-12T19:24:12.530916 #18960] ERROR -- omniauth: (facebook) Authentication failure! no_authorization_code: OmniAuth::Strategies::Facebook::NoAuthorizationCodeError, must pass either a code (via URL or by an fbsr_XXX signed request cookie)

OmniAuth::Strategies::Facebook::NoAuthorizationCodeError (must pass either a code (via URL or by an fbsr_XXX signed request cookie)): omniauth-facebook (2.0.0) lib/omniauth/strategies/facebook.rb:151:in with_authorization_code!' omniauth-facebook (2.0.0) lib/omniauth/strategies/facebook.rb:71:incallback_phase' omniauth (1.2.2) lib/omniauth/strategy.rb:227:in callback_call' omniauth (1.2.2) lib/omniauth/strategy.rb:184:incall!' omniauth (1.2.2) lib/omniauth/strategy.rb:164:in call' omniauth (1.2.2) lib/omniauth/strategy.rb:186:incall!' omniauth (1.2.2) lib/omniauth/strategy.rb:164:in call' omniauth (1.2.2) lib/omniauth/builder.rb:59:incall' rack (1.5.2) lib/rack/etag.rb:23:in call' rack (1.5.2) lib/rack/conditionalget.rb:25:incall' rack (1.5.2) lib/rack/head.rb:11:in call' remotipart (1.2.1) lib/remotipart/middleware.rb:27:incall' actionpack (4.1.8) lib/action_dispatch/middleware/params_parser.rb:27:in call' actionpack (4.1.8) lib/action_dispatch/middleware/flash.rb:254:incall' rack (1.5.2) lib/rack/session/abstract/id.rb:225:in context' rack (1.5.2) lib/rack/session/abstract/id.rb:220:incall' actionpack (4.1.8) lib/action_dispatch/middleware/cookies.rb:560:in call' actionpack (4.1.8) lib/action_dispatch/middleware/callbacks.rb:29:inblock in call' activesupport (4.1.8) lib/active_support/callbacks.rb:82:in run_callbacks' actionpack (4.1.8) lib/action_dispatch/middleware/callbacks.rb:27:incall' actionpack (4.1.8) lib/action_dispatch/middleware/reloader.rb:73:in call' actionpack (4.1.8) lib/action_dispatch/middleware/remote_ip.rb:76:incall' actionpack (4.1.8) lib/action_dispatch/middleware/debug_exceptions.rb:17:in call' actionpack (4.1.8) lib/action_dispatch/middleware/show_exceptions.rb:30:incall' railties (4.1.8) lib/rails/rack/logger.rb:38:in call_app' railties (4.1.8) lib/rails/rack/logger.rb:20:inblock in call' activesupport (4.1.8) lib/active_support/tagged_logging.rb:68:in block in tagged' activesupport (4.1.8) lib/active_support/tagged_logging.rb:26:intagged' activesupport (4.1.8) lib/active_support/tagged_logging.rb:68:in tagged' railties (4.1.8) lib/rails/rack/logger.rb:20:incall' actionpack (4.1.8) lib/action_dispatch/middleware/request_id.rb:21:in call' rack (1.5.2) lib/rack/methodoverride.rb:21:incall' rack (1.5.2) lib/rack/runtime.rb:17:in call' activesupport (4.1.8) lib/active_support/cache/strategy/local_cache_middleware.rb:26:incall' rack (1.5.2) lib/rack/lock.rb:17:in call' actionpack (4.1.8) lib/action_dispatch/middleware/static.rb:84:incall' rack (1.5.2) lib/rack/sendfile.rb:112:in call' railties (4.1.8) lib/rails/engine.rb:514:incall' railties (4.1.8) lib/rails/application.rb:144:in call' rack (1.5.2) lib/rack/lock.rb:17:incall' rack (1.5.2) lib/rack/content_length.rb:14:in call' rack (1.5.2) lib/rack/handler/webrick.rb:60:inservice' /home/sshinde/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/webrick/httpserver.rb:138:in service' /home/sshinde/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/webrick/httpserver.rb:94:inrun' /home/sshinde/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'

I'm assuming here is something wrong with the verify token but I'm not sure how can I get this token.

Please comment

1

1 Answers

0
votes

Your callback url doesn't seem to be implemented you need to actually create it. You are using your login url from OmniAuth which obviously is asking for a code or signed request which has nothing to do with your subscription callback.

Ideally these urls should be different, I don't see any immediate benefit to overloading your login url endpoint with the subscription callback url.

In your login url code, did you

  • Verify the hub.verify_token matches the one you supplied when creating the subscription?
  • Render a response to the GET request that includes only the hub.challenge value?