2014-10-10 57 views
1

我对ruby非常陌生,并且在使用ruby tumblr api时遇到了一些问题。ruby​​ SimpleOAuth错误

执行这个非常简单的测试情况下,当

#!/usr/bin/env ruby 
require 'tumblr_client' 

Tumblr.configure do |config| 
    config.consumer_key = "XXXXXXXXXX" 
    config.consumer_secret = "XXXXXXXXXX" 
    config.oauth_token = "XXXXXXXXXX" 
    config.oauth_token_secret = "XXXXXXXXXX" 
end 

client = Tumblr::Client.new 

puts client.posts("test.tumblr.com") 

我收到此错误信息:

/Library/Ruby/Gems/2.0.0/gems/simple_oauth-0.3.0/lib/simple_oauth/header.rb:88:in `attributes': SimpleOAuth: Found extra option keys not matching ATTRIBUTE_KEYS: (RuntimeError) 
    [:api_host, :consumer_secret, :token_secret] 
    from /Library/Ruby/Gems/2.0.0/gems/simple_oauth-0.3.0/lib/simple_oauth/header.rb:74:in `signed_attributes' 
    from /Library/Ruby/Gems/2.0.0/gems/simple_oauth-0.3.0/lib/simple_oauth/header.rb:80:in `normalized_attributes' 
    from /Library/Ruby/Gems/2.0.0/gems/simple_oauth-0.3.0/lib/simple_oauth/header.rb:62:in `to_s' 
    from /Library/Ruby/Gems/2.0.0/gems/faraday_middleware-0.9.1/lib/faraday_middleware/request/oauth.rb:41:in `call' 
    from /Library/Ruby/Gems/2.0.0/gems/faraday-0.9.0/lib/faraday/rack_builder.rb:139:in `build_response' 
    from /Library/Ruby/Gems/2.0.0/gems/faraday-0.9.0/lib/faraday/connection.rb:377:in `run_request' 
    from /Library/Ruby/Gems/2.0.0/gems/faraday-0.9.0/lib/faraday/connection.rb:140:in `get' 
    from /Library/Ruby/Gems/2.0.0/gems/tumblr_client-0.8.4/lib/tumblr/request.rb:8:in `get_response' 
    from /Library/Ruby/Gems/2.0.0/gems/tumblr_client-0.8.4/lib/tumblr/request.rb:26:in `get' 
    from /Library/Ruby/Gems/2.0.0/gems/tumblr_client-0.8.4/lib/tumblr/blog.rb:40:in `posts' 
    from awd_tumblr.rb:13:in `<main>' 

我知道我已经在过去的一些问题,法拉第版本,并有可能修改一些文件解决它们,但那是很久以前的事了,我不知道我在那里做了什么。

+0

看起来像法拉第中间件传递不能由simple_oauth https://github.com/laserlemon/simple_oauth/blob/消费属性master/lib/simple_oauth/header.rb#L8 – phoet 2014-10-10 12:16:31

+0

但为什么会发生?我能做些什么呢? – Justus1 2014-10-10 14:20:16

回答

3

我把我的应用程序使用simple_oauth-0.2.0

+0

这是怎么做到的? – 2014-11-19 18:11:14

+0

安装0.2.0版本,然后设置版本号并首先加载simple_oauth:// gem'simple_oauth','= 0.2.0' // require'simple_oauth' // require'tumblr_client' – JRQ 2014-11-29 14:48:27

2

我编辑了ruby文件/var/lib/gems/2.1.0/gems/simple_oauth-0.3.0/lib/simple_oauth/header.rb,并评论了警告。有用。

def attributes 
    matching_keys, extra_keys = options.keys.partition { |key| ATTRIBUTE_KEYS.include?(key) } 
    if options[:ignore_extra_keys] || extra_keys.empty? 
    Hash[options.select { |key, _value| matching_keys.include?(key) }.collect { |key, value| [:"oauth_#{key}", value] }] 
    else 
    Hash[options.select { |key, _value| matching_keys.include?(key) }.collect { |key, value| [:"oauth_#{key}", value] }] 
    # fail "SimpleOAuth: Found extra option keys not matching ATTRIBUTE_KEYS:\n [#{extra_keys.collect(&:inspect).join(', ')}]" 
    end 
end