在ROR应用程序中使用Facebook和OAuth登录时出错

时间:2015-10-25 18:13:24

标签: ruby-on-rails ruby facebook oauth

好的,伙计们,我放弃了。 我创建了Rails应用程序并希望登录facebook。 我看了railscast,阅读了一些教程,并在stackoverflow上提出了20多个问题...但我仍然无法在我的网站上使用fb登录.. 所以,请帮我解决这个问题...

的Gemfile

gem 'omniauth-facebook'
gem 'koala', '~> 1.10.0rc'

配置/初始化/ omniauth.rb

OmniAuth.config.logger = Rails.logger

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :facebook, Rails.application.secrets['APP_ID'], Rails.application.secrets['APP_SECRET'], { scope: 'user_about_me' }
end

index.html.slim

h2 Welcome
= link_to 'Login with Facebook', '/auth/facebook'

Facebook - >开发人员 - > MyApp - > Settigns 基础: enter image description here

设置高级 enter image description here

在“使用Facebook登录”链接并在popap中确认后,我有错误:

  

应用程序配置不允许使用URL:一个或   应用程序的设置不允许更多给定的URL。它必须   匹配网站URL或Canvas URL,或域必须是子域   App的一个域名。

有人可以解释我,Facebook或我的手有什么问题吗?

更新: 好的,另一个错误: 当Valid OAuth redirect URIs设置为http://localhost:3000/auth/facebook/callback/时,FACEBOOK会回复错误Given URL is not permitted by the Application configuration: One or more of the given URLs is not permitted 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.

但是当Valid OAuth redirect URIs设置为http://localhost:3000/auth/facebook/callback(最后没有'/')时,我遇到OAuth2错误:OAuth2::Error : {"error":{"message":"Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request","type":"OAuthException","code":100,"fbtrace_id":"EYOCCnhlcFv"}}

1 个答案:

答案 0 :(得分:2)

目前已被打破。现在有一个pr out来修复宝石。

https://github.com/gioblu/omniauth-facebook/commit/eff97bfae32f72821cbccf0b48b78351e41eb585