我正在嘗試將Facebook身份驗證添加到我的網站。到目前爲止,我說:爲什麼omniauth初始化兩次?
的Gemfile
gem 'omniauth-facebook', '1.4.0'
配置/初始化/ omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, 'XXXXXXXXXXXX', 'XXXXXXXXXXXXXXXXXXX', {:provider_ignores_state => true}
end
的config/routes.rb中
match '/auth/:provider/callback', :to => 'sessions#create', as: 'callback'
應用程序/控制器/ sessions_controller.rb
class SessionsController < ApplicationController
def create
render :text => request.env['omniauth.auth'].inspect
end
end
我的問題是,初始化似乎兩次運行。在日誌中軌服務器我看到:
(facebook) Callback phase initiated.
(facebook) Callback phase initiated.
(facebook) Authentication failure! invalid_credentials: OAuth2::Error, :
{"error":{"message":"This authorization code has been used.","type":"OAuthException","code":100}}
(facebook) Authentication failure! invalid_credentials: OAuth2::Error, :
{"error":{"message":"This authorization code has been used.","type":"OAuthException","code":100}}
當我運行rake middleware
我看到OmniAuth::Builder
兩次。任何建議將不勝感激。
不要以爲你使用設計也是你? – Richlewis