1

所以我试图让 oauth authlogic 插件(https://github.com/jrallison/authlogic_oauth)在我已经安装了常规 authlogic 的 rails 应用程序上工作。我相信我已经按照教程设置了所有内容,但是我收到了这个错误:

401 Unauthorized
RAILS_ROOT: c:/goldhat_production

Application Trace | Framework Trace | Full Trace
c:/Ruby/lib/ruby/gems/1.8/gems/oauth-0.4.4/lib/oauth/consumer.rb:217:in `token_request'
c:/Ruby/lib/ruby/gems/1.8/gems/oauth-0.4.4/lib/oauth/consumer.rb:139:in `get_request_token'
c:/goldhat_production/vendor/plugins/authlogic_oauth/lib/authlogic_oauth/oauth_process.rb:21:in `redirect_to_oauth'
c:/goldhat_production/vendor/plugins/authlogic_oauth/lib/authlogic_oauth/oauth_process.rb:10:in `validate_by_oauth'
c:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:178:in `send'
c:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:178:in `evaluate_method'
c:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:166:in `call'
c:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in `run'
c:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in `each'
c:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in `send'
c:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in `run'
c:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:276:in `run_callbacks'
c:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:1098:in `valid_without_callbacks?'
c:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/callbacks.rb:315:in `valid?'
c:/goldhat_production/app/controllers/users_controller.rb:19:in `create'

我在这里几乎迷路了......我做错了什么?如果需要任何其他信息/代码以供参考,我会提供。

编辑:

我在想问题出在这里:我没有令牌或秘密......我从哪里得到这些?

 def self.oauth_consumer
      OAuth::Consumer.new("TOKEN", "SECRET",
      { :site=>"http://twitter.com",
        :authorize_url => "http://twitter.com/oauth/authenticate" })
  end
4

1 回答 1

1

您需要从 twitter 开发页面获取令牌和秘密值,您需要注册您的应用程序以获取这两个值,然后您就可以开始了。

以下是正确 Twitter 页面的链接: http ://dev.twitter.com/login?redirect_after_login=/apps/new

于 2011-05-28T23:20:49.460 回答