【问题标题】:omniauth-facebook 1.5.1 Invalid Credentialsomn​​iauth-facebook 1.5.1 无效凭证
【发布时间】:2013-12-18 13:54:27
【问题描述】:

我用过

gem 'devise',3.2.2
gem 'omniauth'
gem 'omniauth-facebook'

我设置

Application.config.session_store :active_record_store

但是当我

link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider)

我可以看到用户在我的控制台中创建但我没有登录

意味着当我去 /users/sign_in 时仍然需要登录

一般来说登录后无法进入此页面

有人知道吗?

这是我的日志

2013-12-19T04:23:02.188900+00:00 app[web.1]: Started GET "/users/auth/facebook" for 36.224.98.12 at 2013-12-19 04:23:02 +0000
2013-12-19T04:23:02.188900+00:00 app[web.1]: Started GET "/users/auth/facebook" for 36.224.98.12 at 2013-12-19 04:23:02 +0000
2013-12-19T04:23:02.189529+00:00 app[web.1]: I, [2013-12-19T04:23:02.189423 #2]  INFO -- omniauth: (facebook) Request phase initiated.
2013-12-19T04:23:03.499973+00:00 app[web.1]: Started GET "/users/auth/facebook/callback?code=AQBtPAD_sAkIgNKC4VAW8pTE_iTup_Ju-tS1mMBBZ64p1v9PD4liRLZS_Rekah8SqSgvugNTLwxfJqWLOCC_V1m4E4-dhF-wBxSNemax-4X-tH6i-NJ7A7E3JWD51mHA7P8nAoc-o1_NCbgDujac7_WPLzfLFe_tBrVvs-9t2vuSHIS-o0D0ucBiG6cq1wkZL7Buo9qj_yzmlYJgG6jUoWsHDwD3OOgKJ_UWITFBzHqwfymub7h3eZLQmEBzQm2_LOwOFWQoKr3woHyeqd13C1tGjY9xW4yGGkx9SMHJmXNsEDXBFg_c1x-TD4sJqWaQRbQ&state=6335570328a1baae2059bb04ecd91a4e3c66646cb1c88acc" for 36.224.98.12 at 2013-12-19 04:23:03 +0000
2013-12-19T04:23:03.499973+00:00 app[web.1]: Started GET "/users/auth/facebook/callback?code=AQBtPAD_sAkIgNKC4VAW8pTE_iTup_Ju-tS1mMBBZ64p1v9PD4liRLZS_Rekah8SqSgvugNTLwxfJqWLOCC_V1m4E4-dhF-wBxSNemax-4X-tH6i-NJ7A7E3JWD51mHA7P8nAoc-o1_NCbgDujac7_WPLzfLFe_tBrVvs-9t2vuSHIS-o0D0ucBiG6cq1wkZL7Buo9qj_yzmlYJgG6jUoWsHDwD3OOgKJ_UWITFBzHqwfymub7h3eZLQmEBzQm2_LOwOFWQoKr3woHyeqd13C1tGjY9xW4yGGkx9SMHJmXNsEDXBFg_c1x-TD4sJqWaQRbQ&state=6335570328a1baae2059bb04ecd91a4e3c66646cb1c88acc" for 36.224.98.12 at 2013-12-19 04:23:03 +0000
2013-12-19T04:23:03.501144+00:00 app[web.1]: I, [2013-12-19T04:23:03.501033 #2]  INFO -- omniauth: (facebook) Callback phase initiated.
2013-12-19T04:23:03.711366+00:00 app[web.1]: Processing by Users::OmniauthCallbacksController#facebook as HTML
2013-12-19T04:23:03.711366+00:00 app[web.1]: Processing by Users::OmniauthCallbacksController#facebook as HTML
2013-12-19T04:23:03.711366+00:00 app[web.1]:   Parameters: {"code"=>"AQBtPAD_sAkIgNKC4VAW8pTE_iTup_Ju-tS1mMBBZ64p1v9PD4liRLZS_Rekah8SqSgvugNTLwxfJqWLOCC_V1m4E4-dhF-wBxSNemax-4X-tH6i-NJ7A7E3JWD51mHA7P8nAoc-o1_NCbgDujac7_WPLzfLFe_tBrVvs-9t2vuSHIS-o0D0ucBiG6cq1wkZL7Buo9qj_yzmlYJgG6jUoWsHDwD3OOgKJ_UWITFBzHqwfymub7h3eZLQmEBzQm2_LOwOFWQoKr3woHyeqd13C1tGjY9xW4yGGkx9SMHJmXNsEDXBFg_c1x-TD4sJqWaQRbQ", "state"=>"6335570328a1baae2059bb04ecd91a4e3c66646cb1c88acc"}
2013-12-19T04:23:03.711366+00:00 app[web.1]:   Parameters: {"code"=>"AQBtPAD_sAkIgNKC4VAW8pTE_iTup_Ju-tS1mMBBZ64p1v9PD4liRLZS_Rekah8SqSgvugNTLwxfJqWLOCC_V1m4E4-dhF-wBxSNemax-4X-tH6i-NJ7A7E3JWD51mHA7P8nAoc-o1_NCbgDujac7_WPLzfLFe_tBrVvs-9t2vuSHIS-o0D0ucBiG6cq1wkZL7Buo9qj_yzmlYJgG6jUoWsHDwD3OOgKJ_UWITFBzHqwfymub7h3eZLQmEBzQm2_LOwOFWQoKr3woHyeqd13C1tGjY9xW4yGGkx9SMHJmXNsEDXBFg_c1x-TD4sJqWaQRbQ", "state"=>"6335570328a1baae2059bb04ecd91a4e3c66646cb1c88acc"}
2013-12-19T04:23:03.793802+00:00 app[web.1]: Redirected to http://loveturtle.herokuapp.com/
2013-12-19T04:23:03.793802+00:00 app[web.1]: Redirected to http://loveturtle.herokuapp.com/
2013-12-19T04:23:03.794216+00:00 app[web.1]: [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
2013-12-19T04:23:03.861590+00:00 app[web.1]: Completed 302 Found in 150ms (ActiveRecord: 11.4ms)
2013-12-19T04:23:03.861590+00:00 app[web.1]: Completed 302 Found in 150ms (ActiveRecord: 11.4ms)
2013-12-19T04:23:04.105836+00:00 app[web.1]: Processing by TurtlesController#sell_index as HTML
2013-12-19T04:23:04.102915+00:00 app[web.1]: Started GET "/" for 36.224.98.12 at 2013-12-19 04:23:04 +0000

和我的行动

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.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)

  if @user.persisted?
    sign_in_and_redirect root_path, :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 root_path
  end
 end
end

【问题讨论】:

标签: devise ruby-on-rails-4 omniauth


【解决方案1】:

我修好了 在我更改了这些 gem 的版本之后

   Using devise (3.1.1)
   Using oauth2 (0.8.1)
   Using omniauth (1.1.4)
   Using omniauth-oauth2 (1.1.1)
   Using omniauth-facebook (1.4.1)

【讨论】:

    猜你喜欢
    • 2023-03-18
    • 2023-02-01
    • 1970-01-01
    • 2013-03-09
    • 2015-09-29
    • 1970-01-01
    • 1970-01-01
    • 2012-01-06
    • 2011-10-06
    相关资源
    最近更新 更多