Sha256: e30542e95db6451f8d217d1fbb64f529120f59e713a27adf9d3a94a1b200ef67

Contents?: true

Size: 710 Bytes

Versions: 3

Compression:

Stored size: 710 Bytes

Contents

require 'oauth'

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

3 entries across 3 versions & 1 rubygems

Version Path
t-0.9.7 lib/t/authorizable.rb
t-0.9.6 lib/t/authorizable.rb
t-0.9.5 lib/t/authorizable.rb