无法使用facebook

时间:2016-10-07 14:05:26

标签: ruby-on-rails facebook ruby-on-rails-4 heroku

在rails 4上,我正在使用设计来验证我的用户,我还添加了facebook身份验证... 我已按照documentation进行了操作,并在heroku上的config var中进行了设置。

 config.omniauth :facebook, "APP_ID", "APP_SECRET", callback_url: "CALLBACK_URL"

现在当我点击我的网址时,如果点击用facebook链接注册,我就会登陆facebook登录页面(因为我从facebook登出),当我登录登录时,我被重定向到这个: 怎么了? 谢谢你的帮助:)

enter image description here

这是我的日志

at=info method=GET path="/users/auth/facebook/callback?code=AQBSQ125f8npBttjqtAZ4uN9M2-u_DaHqMdp2LJadvBUESXOP_u7q-OL_U0XDlrk836GuXu63OPXAerDTsG7xwgXSg93VgSEMxjs-L733DCsQ1zpoPBMxUgGIQLFb3QxQIqU544ymZuNsDEhdofUj58hrcjOOpg9fEZjQb3lvZqCd34mPt2MVPjQJJAMoe1Vo5n0Y1ozyhYjpSH2DfKTHsmK38ba_7TD8I48M47g0rItI55vvLkrogHLnpgf_NlHjgeHMXldPzsKgEybRM2ouR8S6zKNLsWRJlQ_TbJe_sYuRU85WNoJeAlRrHW-iiw1N4XHIxO2W-JTMG71jwqelSjrPM6c1kPzJbNu-zxjo1vNpQ&state=8a8f36fdd32be2f5931f05ac9176c6f5f5412ef9a8f84eeb" host=duclostutos.herokuapp.com request_id=7968a919-2170-4030-8a32-87d64299e5bf fwd="92.171.113.21" dyno=web.1 connect=0ms service=939ms status=404 bytes=1829

我的路线可能有问题......

Rails.application.routes.draw do

  devise_for :users, only: :omniauth_callbacks, controllers: {omniauth_callbacks: 'users/omniauth_callbacks'}

  scope ":locale", locale: /#{I18n.available_locales.join("|")}/ do

    get "/best_voted", to: "tutos#best_voted"
    resources :tutos
    namespace :users do
      resources :tutos
    end

    resources :tutos, only: [:show]

    resources :tutos do
      member do
        put "like", to: "tutos#upvote"
      end
    end

  as :user do
    get     "/register",  to: "devise/registrations#new", as: :register
    get     "/login",     to: "devise/sessions#new", as: :login
    get     "/logout",    to: "devise/sessions#destroy", as: :logout
    get     "/account",   to: "users#show", as: :account
    get     "/login" ,    to: "devise/sessions#new", as: :new_user_session
    post    "/login" ,    to: "devise/sessions#create", as: :user_session
    delete  "/logout" ,   to: "devise/sessions#destroy", as: :destroy_user_session
  end

    devise_for :users, skip: [:sessions, :omniauth_callbacks]

    resources :users

    root "home#landing"
  end
  get '*path', to: redirect("/#{I18n.default_locale}/%{path}")
  get '', to: redirect("/#{I18n.default_locale}")
end

1 个答案:

答案 0 :(得分:0)

使用此行设置omniauth回调路由

devise_for :users, only: :omniauth_callbacks, controllers: {omniauth_callbacks: 'users/omniauth_callbacks'}

您正在使用此行覆盖您的devise_for:用户路线。

devise_for :users, skip: [:sessions, :omniauth_callbacks]

删除回调路由。

在终端运行中rake:routes查看应用程序的完整路径列表。