antimac.org
Dan's homepage

When trying to generate an OAuth request token, I kept getting a 401 Unauthorized error with moomerman’s twitter_oauth gem.  So I decided to switch to John Nunemaker’s Twitter gem.

This brought about another problem: even if I specified that my Twitter application was web-based and set a callback URL in the app. settings, Twitter kept using the OAuth PIN-based authentication method; I wanted the callback!  The fix involved adding the :o auth_callback parameter to the Twitter::OAuth class, which then gets sent along with the get_request_token() call.

Here’s the monkey-patch:

module Twitter
  class OAuth
    def initialize(ctoken, csecret, options={})
      @ctoken, @csecret, @consumer_options = ctoken, csecret, options

      if options[:sign_in]
        @consumer_options[:authorize_path] =  '/oauth/authenticate'
      end
    end

    def request_token
      @request_token ||= consumer.get_request_token(@consumer_options)
    end
  end
end

I’ll go ahead and slap the old “it works for me” disclaimer on this one. =]

Leave a Reply