【发布时间】:2015-06-23 12:01:41
【问题描述】:
我正在使用 Devise 设置一个 Rails 应用程序 (4.1.10)。我正在使用此设计指南添加 OmniAuth Facebook 集成:https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
我认为我已经设置了我应该设置的所有内容(我知道我应该将 app_id 和 secret 放入 ENV 变量 - 一旦这工作我将继续使用它)但是当我点击我的登录 facebook 链接时出现错误:
https://www.facebook.com/dialog/oauth?client_id=&display=popup&redirect_uri=http%3A%2F%2Fwww.clazzoo.com%2Fusers%2Fauth%2Ffacebook%2Fcallback&response_type=code&scope=email%2Cuser_birthday%2Cread_stream&state=b43008b5d8e714e91ac37b4410f7758655efecbca7bfe98e
Warning
The parameter app_id is required
配置在这里:
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
...
...
config.omniauth :facebook, "1602932433319776", "7221cf917c6e55ba68c8e81145994481",
:scope => 'email,user_birthday,read_stream',
:display => 'popup'
config.omniauth :stripe_connect,
Settings.stripeConnectClientID,
Settings.stripeSecretKey,
:scope => 'read_write',
:stripe_landing => 'register'
end
User 模型具有omniauthable 集:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable,
:omniauthable, :omniauth_providers => [:facebook]
那么为什么当我点击我的链接时会错过相应的 ID?
【问题讨论】:
-
您是否将您的ENV 变量添加到
~/.bashrc? -
我在开发时没有在此测试中使用 ENV 变量 - 它们是硬编码的......根据问题中的代码示例
标签: ruby-on-rails ruby-on-rails-4 devise omniauth omniauth-facebook