我正在使用 Omniauth 登录 Facebook,但是当回调阶段启动时,我收到此错误:
[2015-01-07T02:26:31.113785 #11509] INFO -- omniauth: (facebook) Request phase initiated.
127.0.0.1 - - [07/Jan/2015:02:26:31 +0100] "GET /auth/facebook HTTP/1.1" 302 239 0.0097
I, [2015-01-07T02:26:31.295848 #11509] INFO -- omniauth: (facebook) Callback phase initiated.
ArgumentError: wrong number of arguments (1 for 0)
/home/ciro/.rvm/gems/ruby-2.1.3/gems/cuba-3.3.0/lib/cuba.rb:317:in `get'
/home/ciro/workspace/iParty/app.rb:25:in `block in <top (required)>'
/home/ciro/.rvm/gems/ruby-2.1.3/gems/cuba-3.3.0/lib/cuba.rb:127:in `instance_eval'
/home/ciro/.rvm/gems/ruby-2.1.3/gems/cuba-3.3.0/lib/cuba.rb:127:in `block in call!'
/home/ciro/.rvm/gems/ruby-2.1.3/gems/cuba-3.3.0/lib/cuba.rb:126:in `catch'
/home/ciro/.rvm/gems/ruby-2.1.3/gems/cuba-3.3.0/lib/cuba.rb:126:in `call!'
/home/ciro/.rvm/gems/ruby-2.1.3/gems/cuba-3.3.0/lib/cuba.rb:111:in `call'
/home/ciro/.rvm/gems/ruby-2.1.3/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:404:in `call_app!'
/home/ciro/.rvm/gems/ruby-2.1.3/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:362:in `callback_phase'
/home/ciro/.rvm/gems/ruby-2.1.3/gems/omniauth-oauth2-1.2.0/lib/omniauth/strategies/oauth2.rb:77:in `callback_phase'
/home/ciro/.rvm/gems/ruby-2.1.3/gems/omniauth-facebook-1.6.0/lib/omniauth/strategies/facebook.rb:71:in `callback_phase'
/home/ciro/.rvm/gems/ruby-2.1.3/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:227:in `callback_call'
我使用了Cuba 框架(与 Sinatra 非常相似)。这是我的配置:
应用程序.rb
require "cuba"
require "omniauth-facebook"
Cuba.use Rack::Session::Cookie,
key: ENV['COOKIE_KEY'],
secret: ENV['COOKIE_SECRET']
Cuba.use OmniAuth::Builder do
provider :facebook, ENV['FBK_APP_ID'], ENV['FBK_APP_SECRET']
end
Cuba.define do
on get '/auth/facebook/callback' do
res.write "Autentication with Facebook was successful!"
end
on get '/auth/failure' do
res.write "Something was wrong with Facebook authentication"
end
end
什么不见了?