1

我正在使用下面的代码:

require 'grape'
require 'omniauth'
require 'omniauth-facebook'

class Auth < Grape::API
  include OmniAuth::Strategy

  format :json

  use Rack::Session::Cookie
  use OmniAuth::Strategies::Facebook, 'xx', 'xxx'

end

我究竟做错了什么?当我访问时,/auth/facebook我得到了一条丢失的路线。

4

1 回答 1

1

您应该将omniauth 内容添加到您的config.ru 文件中:

require 'omniauth'
require 'omniauth-facebook'

use Rack::Session::Cookie, secret: 'some long secret code here'

use OmniAuth::Builder do
  provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET']
end

# run your base api here. Root, Base, whatever you called it.
run API::Root
于 2014-01-05T21:19:43.060 回答