Sha256: c21f80ef5b6a260683d0f32c3d9a1de448b608fbaa11412f3f6fe592a83e4cf5

Contents?: true

Size: 693 Bytes

Versions: 5

Compression:

Stored size: 693 Bytes

Contents

module T
  module Authorizable

    def consumer
      OAuth::Consumer.new(
        options['consumer-key'],
        options['consumer-secret'],
        :site => base_url
      )
    end

    def generate_authorize_url(request_token)
      request = consumer.create_signed_request(:get, consumer.authorize_path, request_token, pin_auth_parameters)
      params = request['Authorization'].sub(/^OAuth\s+/, '').split(/,\s+/).map do |param|
        key, value = param.split('=')
        value =~ /"(.*?)"/
        "#{key}=#{CGI::escape($1)}"
      end.join('&')
      "#{base_url}#{request.path}?#{params}"
    end

    def pin_auth_parameters
      {:oauth_callback => 'oob'}
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
t-0.9.4 lib/t/authorizable.rb
t-0.9.3 lib/t/authorizable.rb
t-0.9.2 lib/t/authorizable.rb
t-0.9.1 lib/t/authorizable.rb
t-0.9.0 lib/t/authorizable.rb