0
私はomniauthとdevise_token_authに問題があります。 Facebookにユーザーを登録しようとすると、コールバックが機能しません。Users :: OmniauthCallbacksControllerの 'redirect_callbacks'アクションが見つかりません
彼女は私のGemfileです:
gem 'rack-cors', :require => 'rack/cors'
gem 'devise_token_auth'
gem 'omniauth'
gem 'omniauth-facebook'
gem 'devise', '~> 3.2'
routes.rbを
Rails.application.routes.draw do
namespace :api, defaults: { format: :json } do
scope :v1 do
mount_devise_token_auth_for 'User', at: 'auth', :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
match 'auth/:provider/callback', to: 'sessions#create', via: [:get, :post]
end
end
root to:'welcomes#index'
end
ここアプリ/コントローラ/ユーザ/ omniauth_callbacks_controller.rb
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
# You need to implement the method below in your model (e.g. app/models/user.rb)
@user = User.from_omniauth(request.env["omniauth.auth"])
if @user.persisted?
sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format?
else
session["devise.facebook_data"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
def failure
redirect_to root_path
end
end
です
設定/初期化子/ omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, "XXX", "XXX",
:scope => 'public_profile,email,user_birthday',
:info_fields => 'id,about,birthday,email,first_name,gender,last_name'
end
そして最後に、これは、コンソールの応答です:
Started GET "/api/v1/auth/facebook" for 192.168.33.1 at 2016-05-14 10:26:00 +0000
Cannot render console from 192.168.33.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Started GET "/omniauth/facebook?resource_class=User" for 192.168.33.1 at 2016-05-14 10:26:00 +0000
Cannot render console from 192.168.33.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
I, [2016-05-14T10:26:00.995076 #3226] INFO -- omniauth: (facebook) Request phase initiated.
Started GET "/omniauth/facebook/callback?code=XXX" for 192.168.33.1 at 2016-05-14 10:26:01 +0000
Cannot render console from 192.168.33.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
I, [2016-05-14T10:26:01.130357 #3226] INFO -- omniauth: (facebook) Callback phase initiated.
AbstractController::ActionNotFound (The action 'redirect_callbacks' could not be found for Users::OmniauthCallbacksController):
私は、単純な何かが足りないのですか?私は最後の数日間の解決策を探しています
ありがとう!それはうまくいっている! – Shinix