我使用https://github.com/plataformatec/devise/wiki/OmniAuth%3a-Overview集成omniauth Facebook的无法从Facebook验证您的身份。但我得到的错误:Rails的:因为“证书无效”
Could not authenticate you from Facebook because "Invalid credentials".
我有设计安装。当我点击Facebook登录链接时,它会将我重定向到Facebook登录。当我输入我的详细信息时,它会回到设计标志并给出上述错误。我在https://github.com/plataformatec/devise/wiki/OmniAuth%3a-Overview上检查了“Invalid credentials”的解决方案,我的应用是为App Type = Web设置的头文件。没有得到它为什么不工作。
而且我的应用程序上线,但尚未从Facebook批准。但我不认为它与这个错误有关。以下是东西我做了omniauth Facebook的:
Gemfile中包含:
gem 'omniauth'
gem 'omniauth-facebook', '1.4.0'
在用户模型,补充说:
devise :omniauthable, :omniauth_providers => [:facebook]
attr_accessible :provider, :uid
def self.find_for_facebook_oauth(auth, signed_in_resource=nil)
user = User.where(:provider => auth.provider, :uid => auth.uid).first
unless user
user = User.create(name:auth.extra.raw_info.name,
provider:auth.provider,
uid:auth.uid,
email:auth.info.email,
password:Devise.friendly_token[0,20]
)
end
user
end
devise.rb
require "omniauth-facebook"
config.omniauth :facebook, "APP_ID", "APP_SECRET", :scope => "offline_access, email"
链接facebook sign_in:
<%= link_to "Sign in with Facebook", user_omniauth_authorize_path(:facebook) %>
route.rb:
devise_for:用户,:控制器=> {:omniauth_callbacks => “omniauth_callbacks”}
Omniauth控制器:
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
@user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)
if @user.persisted?
sign_in_and_redirect @user, :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 new_user_registration_url
end
end
end
可以在这个人的帮助?
我不知道这件事,但可能是因为你的电子邮件地址在你的omniauth范围之内有空间吗? 我有同样的错误由于一个错字 – golfadas 2013-08-21 13:33:59
可能重复[Rails的:无法从Facebook验证您的身份,因为“无效凭证”(http://stackoverflow.com/questions/16176208/rails-could-not-authenticate- you-from-facebook-because-invalid-credentials) – mindriot 2014-09-02 08:08:21
这已被标记为您发布的具有更多信息的相同问题的副本。将来如果您有其他信息要添加到问题中,请编辑现有问题,而不是开始新问题。对于omniauth-facebook(1.4.0), – mindriot 2014-09-02 08:17:57