【问题标题】:ruby on rails omniauth and omniauth-facebookruby on rails omniauth 和 omniauth-facebook
【发布时间】:2013-07-10 23:13:41
【问题描述】:

我的应用程序是用 ruby​​ on rails 制作的,它使用了omniauth 和omniauth-facebook gems。它由一个“使用 Facebook 登录”按钮组成。它在 localhost 中运行良好——人们可以使用 Facebook 登录——但我无法让它在我的实时服务器上运行。据我所知,我已经更改了相关的详细信息,但有什么我遗漏的吗?

正如我所说,它在 localhost:3000 中运行良好。我已更改这些详细信息以尝试使其在 www.example.com 上运行,但我不断收到错误消息:

Given URL is not permitted by the application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.

在我的 config/oauth.yml 文件中,我有:

development:
  facebook:
    app_id: "12345"
    app_secret: "abcde"
    options:
      scope: "email"
      display: "page"

staging: &staging
  facebook:
    app_id: "12345"
    app_secret: "abcde"
    options:
      scope: "email"
      display: "page"

test:
  <<: *staging

production:
  facebook:
    app_id: "12345678"
    app_secret: "abcdefgh"

我已更改“生产”中的 app_id 和 app_secret 以匹配我在 Facebook 中创建的应用程序的 ID 和密码。

在environments/production.rb我放了:

  # Need this here for mailing purposes
  config.action_mailer.default_url_options = { :host => 'www.example.com' }

在environments/development.rb我放了:

  # Don't care if the mailer can't send
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.default_url_options = { :host => 'www.example.com' }

我是否忽略了什么?也许我需要在我的 Facebook 应用程序部分更改一些东西,它给了我 id 和秘密?任何帮助将不胜感激。

【问题讨论】:

  • 您的应用程序域设置是什么?是example.com吗?
  • 在 Facebook 中显示“App Domains”的地方,我有 www.example.com。
  • 在“使用 Facebook 登录的网站,网址:”我有 example.com

标签: ruby-on-rails omniauth


【解决方案1】:

在使用 Facebook 登录的网站上,网站 url 应设置为您网站的 URL,在应用程序域上设置为您的主机,例如:

应用域名::example.com

网站网址:http://example.com/

environments/production.rb 你应该输入:

  config.action_mailer.default_url_options = { :host => 'example.com' }

【讨论】:

  • 为此干杯,谢谢。虽然仍然无法让它工作。我完全按照描述放置了 App Domain 和 Site Url。还有什么可能吗?我不断收到该消息,“应用程序配置不允许给定 URL....”您可以在此处查看,单击 Facebook 按钮。populisto.com/login
  • @ChristopheHarris 嘿,你有想过这个吗?
  • @chamini2 是的,我做到了,但不记得怎么做了。无论如何,我已经在 rails4 和 ruby​​2 中重建了我的项目。这些教程很有帮助-coderwall.com/p/bsfitwgithub.com/plataformatec/devise/wiki/OmniAuth:-Overview
【解决方案2】:

当我正确完成所有设置时,同样的事情发生在我身上。结果发现,在我的 Facebook 仪表板上,App ID 和 App Secret 不知何故发生了变化。您可能在仪表板上进行了更改,以某种方式更改了 ID 和 Secret。请再次确认这些详细信息

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-14
    • 2017-11-14
    • 2014-02-14
    • 1970-01-01
    • 2013-05-30
    • 1970-01-01
    • 2012-02-08
    • 1970-01-01
    相关资源
    最近更新 更多