1

I am very new to ruby and have some problems using the ruby tumblr api.

when executing this very simple test case:

#!/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")

I get this error message:

/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>'

I know I had some problems with faraday versions in the past and might have edited some files to resolve them, but that was a long time ago, and I have no idea what I did there.

Justus1
  • 473
  • 1
  • 4
  • 13
  • looks like the faraday middleware is passing attributes that can not be consumed by simple_oauth https://github.com/laserlemon/simple_oauth/blob/master/lib/simple_oauth/header.rb#L8 – phoet Oct 10 '14 at 12:16
  • but why would that happen? and what can i do about that? – Justus1 Oct 10 '14 at 14:20

3 Answers3

3

I set my app to use simple_oauth-0.2.0

richy
  • 2,716
  • 1
  • 33
  • 42
2

I edited the ruby file /var/lib/gems/2.1.0/gems/simple_oauth-0.3.0/lib/simple_oauth/header.rb, and commented the warning. It works.

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
Nope
  • 897
  • 1
  • 8
  • 15
0

i now downloaded an earlier version from https://github.com/laserlemon/simple_oauth/tree/466ea5c7b8094a93d34d6bc6e6ea1b2c4f8d708c and simply copied the files in my simple_oauth-0.3.0 folder.

that way it is working again.

Justus1
  • 473
  • 1
  • 4
  • 13