在ROR应用程序中使用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 Basic: 在此处输入图像描述

设置高级 在此处输入图像描述

在“使用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. 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"}}

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

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