1

I'm trying to use Omniauth to allow users to login to my Rails app using Facebook. Locally, omniauth automatically redirects the browser to Facebook for authentication using the following link:

<%= link_to "Sign in with Facebook", "/auth/facebook" %>

It redirects back as is expected (no callback error) and I am then able to log out.

The issue occurs when I try to upload my application to my server. For some reason Omniauth isn't kicking in and it doesn't do the redirect. Instead it just points the browser to a non-existant directory in my app (http://sharedchecklist.com/auth/facebook) and spits out this error:

Routing Error

No route matches "/auth/facebook"

I've done a lot of searching over the past few hours to try and figure out what the issue could be. I've made sure to changee the the site and canvas URLs to my app's address. It isn't an issue with callback.

It's almost like omniauth isn't there…</p>

Has anyone encountered this issue before? I'm fairly new to rails but I've been able to figure through any issues before which makes this one all the most frustrating.

If the url would help, here it is: http://sharedchecklist.com/

Thanks for any assistance you can offer.

4

3 回答 3

0

您需要告诉 Facebook 重定向到哪里。如果它在开发中有效,您可能会将您的站点 url 设置为“http://localhost:3000”。将其更改为“http://sharedchecklist.com”,它将起作用。当然,它会在开发中中断。因此,我为我的测试创建了一个新的“测试”Facebook 应用程序,它总是重定向到本地主机。

于 2011-02-21T05:49:37.440 回答
0

如果您想在本地主机上进行测试并保持生产环境正常工作:

1- 仅为开发目的创建一个新的 Facebook 应用

2- 将站点 URL 字段设置为:http://localhost:3000/

3-然后编辑您的/config/initializers/omniauth.rb文件以匹配以下内容:

OmniAuth.config.logger = Rails.logger

Rails.application.config.middleware.use OmniAuth::Builder do
  if Rails.env.development?
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
    provider :facebook, 'DEV_APP_ID', 'DEV_APP_SEVRET'
  else
    provider :facebook, 'DEPLOY_APP_ID', 'DEPLOY_APP_SECRET'
  end
end

最后重新启动rails server,您应该能够通过您的新应用程序登录。

于 2012-10-25T14:58:45.573 回答
0

如果缺少 config/initializers/omniauth.rb,这似乎会发生。

我在忽略列表中有该文件,并且有一个示例文件作为omniauth.rb.sample。我忘了创建omniauth.rb 文件,我得到了同样的错误。

于 2011-03-09T19:08:13.437 回答