oauth 0.5.5 → 0.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +415 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/CONTRIBUTING.md +23 -0
- data/LICENSE +18 -17
- data/README.md +372 -0
- data/SECURITY.md +16 -0
- data/bin/oauth +2 -2
- data/lib/oauth/cli/authorize_command.rb +8 -10
- data/lib/oauth/cli/base_command.rb +9 -7
- data/lib/oauth/cli/query_command.rb +3 -3
- data/lib/oauth/cli/sign_command.rb +12 -15
- data/lib/oauth/cli.rb +19 -19
- data/lib/oauth/client/action_controller_request.rb +20 -21
- data/lib/oauth/client/em_http.rb +99 -99
- data/lib/oauth/client/helper.rb +33 -36
- data/lib/oauth/client/net_http.rb +30 -30
- data/lib/oauth/consumer.rb +90 -89
- data/lib/oauth/errors/unauthorized.rb +3 -1
- data/lib/oauth/errors.rb +3 -3
- data/lib/oauth/helper.rb +17 -13
- data/lib/oauth/oauth.rb +4 -4
- data/lib/oauth/oauth_test_helper.rb +4 -4
- data/lib/oauth/request_proxy/action_controller_request.rb +56 -53
- data/lib/oauth/request_proxy/action_dispatch_request.rb +8 -4
- data/lib/oauth/request_proxy/base.rb +136 -132
- data/lib/oauth/request_proxy/curb_request.rb +49 -43
- data/lib/oauth/request_proxy/em_http_request.rb +59 -49
- data/lib/oauth/request_proxy/jabber_request.rb +12 -9
- data/lib/oauth/request_proxy/mock_request.rb +4 -2
- data/lib/oauth/request_proxy/net_http.rb +63 -54
- data/lib/oauth/request_proxy/rack_request.rb +35 -31
- data/lib/oauth/request_proxy/rest_client_request.rb +53 -50
- data/lib/oauth/request_proxy/typhoeus_request.rb +51 -45
- data/lib/oauth/request_proxy.rb +3 -3
- data/lib/oauth/server.rb +10 -12
- data/lib/oauth/signature/base.rb +10 -9
- data/lib/oauth/signature/hmac/sha1.rb +4 -4
- data/lib/oauth/signature/hmac/sha256.rb +17 -0
- data/lib/oauth/signature/plaintext.rb +2 -2
- data/lib/oauth/signature/rsa/sha1.rb +5 -5
- data/lib/oauth/signature.rb +5 -5
- data/lib/oauth/token.rb +5 -5
- data/lib/oauth/tokens/access_token.rb +3 -3
- data/lib/oauth/tokens/consumer_token.rb +2 -2
- data/lib/oauth/tokens/request_token.rb +7 -8
- data/lib/oauth/tokens/server_token.rb +0 -1
- data/lib/oauth/version.rb +1 -1
- data/lib/oauth.rb +8 -6
- metadata +47 -99
- data/README.rdoc +0 -88
@@ -1,21 +1,21 @@
|
|
1
1
|
if defined? ActionDispatch
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
2
|
+
require "oauth/request_proxy/rack_request"
|
3
|
+
require "oauth/request_proxy/action_dispatch_request"
|
4
|
+
require "action_dispatch/testing/test_process"
|
5
5
|
else
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require "oauth/request_proxy/action_controller_request"
|
7
|
+
require "action_controller/test_process"
|
8
8
|
end
|
9
9
|
|
10
10
|
module ActionController
|
11
11
|
class Base
|
12
12
|
if defined? ActionDispatch
|
13
|
-
def process_with_new_base_test(request, response=nil)
|
13
|
+
def process_with_new_base_test(request, response = nil)
|
14
14
|
request.apply_oauth! if request.respond_to?(:apply_oauth!)
|
15
15
|
super(request, response)
|
16
16
|
end
|
17
17
|
else
|
18
|
-
def process_with_oauth(request, response=nil)
|
18
|
+
def process_with_oauth(request, response = nil)
|
19
19
|
request.apply_oauth! if request.respond_to?(:apply_oauth!)
|
20
20
|
process_without_oauth(request, response)
|
21
21
|
end
|
@@ -24,8 +24,8 @@ module ActionController
|
|
24
24
|
end
|
25
25
|
|
26
26
|
class TestRequest
|
27
|
-
|
28
|
-
|
27
|
+
class << self
|
28
|
+
attr_writer :use_oauth
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.use_oauth?
|
@@ -33,33 +33,32 @@ module ActionController
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def configure_oauth(consumer = nil, token = nil, options = {})
|
36
|
-
@oauth_options = { :
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
36
|
+
@oauth_options = { consumer: consumer,
|
37
|
+
token: token,
|
38
|
+
scheme: "header",
|
39
|
+
signature_method: nil,
|
40
|
+
nonce: nil,
|
41
|
+
timestamp: nil }.merge(options)
|
42
42
|
end
|
43
43
|
|
44
44
|
def apply_oauth!
|
45
45
|
return unless ActionController::TestRequest.use_oauth? && @oauth_options
|
46
46
|
|
47
|
-
@oauth_helper = OAuth::Client::Helper.new(self, @oauth_options.merge(:
|
47
|
+
@oauth_helper = OAuth::Client::Helper.new(self, @oauth_options.merge(request_uri: (respond_to?(:fullpath) ? fullpath : request_uri)))
|
48
48
|
@oauth_helper.amend_user_agent_header(env)
|
49
49
|
|
50
|
-
|
50
|
+
send("set_oauth_#{@oauth_options[:scheme]}")
|
51
51
|
end
|
52
52
|
|
53
53
|
def set_oauth_header
|
54
|
-
env[
|
54
|
+
env["Authorization"] = @oauth_helper.header
|
55
55
|
end
|
56
56
|
|
57
57
|
def set_oauth_parameters
|
58
58
|
@query_parameters = @oauth_helper.parameters_with_oauth
|
59
|
-
@query_parameters.merge!(:
|
59
|
+
@query_parameters.merge!(oauth_signature: @oauth_helper.signature)
|
60
60
|
end
|
61
61
|
|
62
|
-
def set_oauth_query_string
|
63
|
-
end
|
62
|
+
def set_oauth_query_string; end
|
64
63
|
end
|
65
64
|
end
|
data/lib/oauth/client/em_http.rb
CHANGED
@@ -1,119 +1,119 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "em-http"
|
2
|
+
require "oauth/helper"
|
3
|
+
require "oauth/request_proxy/em_http_request"
|
4
4
|
|
5
5
|
# Extensions for em-http so that we can use consumer.sign! with an EventMachine::HttpClient
|
6
6
|
# instance. This is purely syntactic sugar.
|
7
|
-
|
7
|
+
module EventMachine
|
8
|
+
class HttpClient
|
9
|
+
attr_reader :oauth_helper
|
8
10
|
|
9
|
-
|
11
|
+
# Add the OAuth information to an HTTP request. Depending on the <tt>options[:scheme]</tt> setting
|
12
|
+
# this may add a header, additional query string parameters, or additional POST body parameters.
|
13
|
+
# The default scheme is +header+, in which the OAuth parameters as put into the +Authorization+
|
14
|
+
# header.
|
15
|
+
#
|
16
|
+
# * http - Configured Net::HTTP instance, ignored in this scenario except for getting host.
|
17
|
+
# * consumer - OAuth::Consumer instance
|
18
|
+
# * token - OAuth::Token instance
|
19
|
+
# * options - Request-specific options (e.g. +request_uri+, +consumer+, +token+, +scheme+,
|
20
|
+
# +signature_method+, +nonce+, +timestamp+)
|
21
|
+
#
|
22
|
+
# This method also modifies the <tt>User-Agent</tt> header to add the OAuth gem version.
|
23
|
+
#
|
24
|
+
# See Also: {OAuth core spec version 1.0, section 5.4.1}[http://oauth.net/core/1.0#rfc.section.5.4.1]
|
25
|
+
def oauth!(http, consumer = nil, token = nil, options = {})
|
26
|
+
options = { request_uri: normalized_oauth_uri(http),
|
27
|
+
consumer: consumer,
|
28
|
+
token: token,
|
29
|
+
scheme: "header",
|
30
|
+
signature_method: nil,
|
31
|
+
nonce: nil,
|
32
|
+
timestamp: nil }.merge(options)
|
10
33
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
# header.
|
15
|
-
#
|
16
|
-
# * http - Configured Net::HTTP instance, ignored in this scenario except for getting host.
|
17
|
-
# * consumer - OAuth::Consumer instance
|
18
|
-
# * token - OAuth::Token instance
|
19
|
-
# * options - Request-specific options (e.g. +request_uri+, +consumer+, +token+, +scheme+,
|
20
|
-
# +signature_method+, +nonce+, +timestamp+)
|
21
|
-
#
|
22
|
-
# This method also modifies the <tt>User-Agent</tt> header to add the OAuth gem version.
|
23
|
-
#
|
24
|
-
# See Also: {OAuth core spec version 1.0, section 5.4.1}[http://oauth.net/core/1.0#rfc.section.5.4.1]
|
25
|
-
def oauth!(http, consumer = nil, token = nil, options = {})
|
26
|
-
options = { :request_uri => normalized_oauth_uri(http),
|
27
|
-
:consumer => consumer,
|
28
|
-
:token => token,
|
29
|
-
:scheme => 'header',
|
30
|
-
:signature_method => nil,
|
31
|
-
:nonce => nil,
|
32
|
-
:timestamp => nil }.merge(options)
|
33
|
-
|
34
|
-
@oauth_helper = OAuth::Client::Helper.new(self, options)
|
35
|
-
self.__send__(:"set_oauth_#{options[:scheme]}")
|
36
|
-
end
|
34
|
+
@oauth_helper = OAuth::Client::Helper.new(self, options)
|
35
|
+
__send__(:"set_oauth_#{options[:scheme]}")
|
36
|
+
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
38
|
+
# Create a string suitable for signing for an HTTP request. This process involves parameter
|
39
|
+
# normalization as specified in the OAuth specification. The exact normalization also depends
|
40
|
+
# on the <tt>options[:scheme]</tt> being used so this must match what will be used for the request
|
41
|
+
# itself. The default scheme is +header+, in which the OAuth parameters as put into the +Authorization+
|
42
|
+
# header.
|
43
|
+
#
|
44
|
+
# * http - Configured Net::HTTP instance
|
45
|
+
# * consumer - OAuth::Consumer instance
|
46
|
+
# * token - OAuth::Token instance
|
47
|
+
# * options - Request-specific options (e.g. +request_uri+, +consumer+, +token+, +scheme+,
|
48
|
+
# +signature_method+, +nonce+, +timestamp+)
|
49
|
+
#
|
50
|
+
# See Also: {OAuth core spec version 1.0, section 9.1.1}[http://oauth.net/core/1.0#rfc.section.9.1.1]
|
51
|
+
def signature_base_string(http, consumer = nil, token = nil, options = {})
|
52
|
+
options = { request_uri: normalized_oauth_uri(http),
|
53
|
+
consumer: consumer,
|
54
|
+
token: token,
|
55
|
+
scheme: "header",
|
56
|
+
signature_method: nil,
|
57
|
+
nonce: nil,
|
58
|
+
timestamp: nil }.merge(options)
|
59
59
|
|
60
|
-
|
61
|
-
|
60
|
+
OAuth::Client::Helper.new(self, options).signature_base_string
|
61
|
+
end
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
63
|
+
# This code was lifted from the em-http-request because it was removed from
|
64
|
+
# the gem June 19, 2010
|
65
|
+
# see: http://github.com/igrigorik/em-http-request/commit/d536fc17d56dbe55c487eab01e2ff9382a62598b
|
66
|
+
def normalize_uri
|
67
|
+
@normalized_uri ||= begin
|
68
|
+
uri = @conn.dup
|
69
|
+
encoded_query = encode_query(@conn, @req[:query])
|
70
|
+
path, query = encoded_query.split("?", 2)
|
71
|
+
uri.query = query unless encoded_query.empty?
|
72
|
+
uri.path = path
|
73
|
+
uri
|
74
|
+
end
|
74
75
|
end
|
75
|
-
end
|
76
76
|
|
77
|
-
|
77
|
+
protected
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
79
|
+
def combine_query(path, query, uri_query)
|
80
|
+
combined_query = if query.is_a?(Hash)
|
81
|
+
query.map { |k, v| encode_param(k, v) }.join("&")
|
82
|
+
else
|
83
|
+
query.to_s
|
84
|
+
end
|
85
|
+
unless uri_query.to_s.empty?
|
86
|
+
combined_query = [combined_query, uri_query].reject(&:empty?).join("&")
|
87
|
+
end
|
88
|
+
combined_query.to_s.empty? ? path : "#{path}?#{combined_query}"
|
84
89
|
end
|
85
|
-
if !uri_query.to_s.empty?
|
86
|
-
combined_query = [combined_query, uri_query].reject {|part| part.empty?}.join("&")
|
87
|
-
end
|
88
|
-
combined_query.to_s.empty? ? path : "#{path}?#{combined_query}"
|
89
|
-
end
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
91
|
+
# Since we expect to get the host etc details from the http instance (...),
|
92
|
+
# we create a fake url here. Surely this is a horrible, horrible idea?
|
93
|
+
def normalized_oauth_uri(http)
|
94
|
+
uri = URI.parse(normalize_uri.path)
|
95
|
+
uri.host = http.address
|
96
|
+
uri.port = http.port
|
97
97
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
98
|
+
uri.scheme = if http.respond_to?(:use_ssl?) && http.use_ssl?
|
99
|
+
"https"
|
100
|
+
else
|
101
|
+
"http"
|
102
|
+
end
|
103
|
+
uri.to_s
|
102
104
|
end
|
103
|
-
uri.to_s
|
104
|
-
end
|
105
105
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
106
|
+
def set_oauth_header
|
107
|
+
req[:head] ||= {}
|
108
|
+
req[:head].merge!("Authorization" => @oauth_helper.header)
|
109
|
+
end
|
110
110
|
|
111
|
-
|
112
|
-
|
113
|
-
|
111
|
+
def set_oauth_body
|
112
|
+
raise NotImplementedError, "please use the set_oauth_header method instead"
|
113
|
+
end
|
114
114
|
|
115
|
-
|
116
|
-
|
115
|
+
def set_oauth_query_string
|
116
|
+
raise NotImplementedError, "please use the set_oauth_header method instead"
|
117
|
+
end
|
117
118
|
end
|
118
|
-
|
119
119
|
end
|
data/lib/oauth/client/helper.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require "oauth/client"
|
2
|
+
require "oauth/consumer"
|
3
|
+
require "oauth/helper"
|
4
|
+
require "oauth/token"
|
5
|
+
require "oauth/signature/hmac/sha1"
|
6
6
|
|
7
7
|
module OAuth::Client
|
8
8
|
class Helper
|
@@ -11,12 +11,10 @@ module OAuth::Client
|
|
11
11
|
def initialize(request, options = {})
|
12
12
|
@request = request
|
13
13
|
@options = options
|
14
|
-
@options[:signature_method] ||=
|
14
|
+
@options[:signature_method] ||= "HMAC-SHA1"
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
@options
|
19
|
-
end
|
17
|
+
attr_reader :options
|
20
18
|
|
21
19
|
def nonce
|
22
20
|
options[:nonce] ||= generate_key
|
@@ -28,38 +26,37 @@ module OAuth::Client
|
|
28
26
|
|
29
27
|
def oauth_parameters
|
30
28
|
out = {
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
29
|
+
"oauth_body_hash" => options[:body_hash],
|
30
|
+
"oauth_callback" => options[:oauth_callback],
|
31
|
+
"oauth_consumer_key" => options[:consumer].key,
|
32
|
+
"oauth_token" => options[:token] ? options[:token].token : "",
|
33
|
+
"oauth_signature_method" => options[:signature_method],
|
34
|
+
"oauth_timestamp" => timestamp,
|
35
|
+
"oauth_nonce" => nonce,
|
36
|
+
"oauth_verifier" => options[:oauth_verifier],
|
37
|
+
"oauth_version" => (options[:oauth_version] || "1.0"),
|
38
|
+
"oauth_session_handle" => options[:oauth_session_handle]
|
41
39
|
}
|
42
40
|
allowed_empty_params = options[:allow_empty_params]
|
43
|
-
if allowed_empty_params != true && !allowed_empty_params.
|
41
|
+
if allowed_empty_params != true && !allowed_empty_params.is_a?(Array)
|
44
42
|
allowed_empty_params = allowed_empty_params == false ? [] : [allowed_empty_params]
|
45
43
|
end
|
46
|
-
out.select! { |k,v| v.to_s !=
|
44
|
+
out.select! { |k, v| v.to_s != "" || allowed_empty_params == true || allowed_empty_params.include?(k) }
|
47
45
|
out
|
48
46
|
end
|
49
47
|
|
50
48
|
def signature(extra_options = {})
|
51
|
-
OAuth::Signature.sign(@request, { :
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
55
|
-
}.merge(extra_options) )
|
49
|
+
OAuth::Signature.sign(@request, { uri: options[:request_uri],
|
50
|
+
consumer: options[:consumer],
|
51
|
+
token: options[:token],
|
52
|
+
unsigned_parameters: options[:unsigned_parameters] }.merge(extra_options))
|
56
53
|
end
|
57
54
|
|
58
55
|
def signature_base_string(extra_options = {})
|
59
|
-
OAuth::Signature.signature_base_string(@request, { :
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
56
|
+
OAuth::Signature.signature_base_string(@request, { uri: options[:request_uri],
|
57
|
+
consumer: options[:consumer],
|
58
|
+
token: options[:token],
|
59
|
+
parameters: oauth_parameters }.merge(extra_options))
|
63
60
|
end
|
64
61
|
|
65
62
|
def token_request?
|
@@ -67,24 +64,24 @@ module OAuth::Client
|
|
67
64
|
end
|
68
65
|
|
69
66
|
def hash_body
|
70
|
-
@options[:body_hash] = OAuth::Signature.body_hash(@request, :
|
67
|
+
@options[:body_hash] = OAuth::Signature.body_hash(@request, parameters: oauth_parameters)
|
71
68
|
end
|
72
69
|
|
73
70
|
def amend_user_agent_header(headers)
|
74
71
|
@oauth_ua_string ||= "OAuth gem v#{OAuth::VERSION}"
|
75
72
|
# Net::HTTP in 1.9 appends Ruby
|
76
|
-
if headers[
|
77
|
-
headers[
|
73
|
+
if headers["User-Agent"] && headers["User-Agent"] != "Ruby"
|
74
|
+
headers["User-Agent"] += " (#{@oauth_ua_string})"
|
78
75
|
else
|
79
|
-
headers[
|
76
|
+
headers["User-Agent"] = @oauth_ua_string
|
80
77
|
end
|
81
78
|
end
|
82
79
|
|
83
80
|
def header
|
84
81
|
parameters = oauth_parameters
|
85
|
-
parameters
|
82
|
+
parameters["oauth_signature"] = signature(options.merge(parameters: parameters))
|
86
83
|
|
87
|
-
header_params_str = parameters.sort.map { |k,v| "#{k}=\"#{escape(v)}\"" }.join(
|
84
|
+
header_params_str = parameters.sort.map { |k, v| "#{k}=\"#{escape(v)}\"" }.join(", ")
|
88
85
|
|
89
86
|
realm = "realm=\"#{options[:realm]}\", " if options[:realm]
|
90
87
|
"OAuth #{realm}#{header_params_str}"
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "oauth/helper"
|
2
|
+
require "oauth/request_proxy/net_http"
|
3
3
|
|
4
4
|
class Net::HTTPGenericRequest
|
5
5
|
include OAuth::Helper
|
@@ -27,7 +27,7 @@ class Net::HTTPGenericRequest
|
|
27
27
|
@oauth_helper = OAuth::Client::Helper.new(self, helper_options)
|
28
28
|
@oauth_helper.amend_user_agent_header(self)
|
29
29
|
@oauth_helper.hash_body if oauth_body_hash_required?
|
30
|
-
|
30
|
+
send("set_oauth_#{helper_options[:scheme]}")
|
31
31
|
end
|
32
32
|
|
33
33
|
# Create a string suitable for signing for an HTTP request. This process involves parameter
|
@@ -52,34 +52,34 @@ class Net::HTTPGenericRequest
|
|
52
52
|
@oauth_helper.signature_base_string
|
53
53
|
end
|
54
54
|
|
55
|
-
private
|
55
|
+
private
|
56
56
|
|
57
57
|
def oauth_helper_options(http, consumer, token, options)
|
58
|
-
{ :
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
63
|
-
:
|
64
|
-
:
|
58
|
+
{ request_uri: oauth_full_request_uri(http, options),
|
59
|
+
consumer: consumer,
|
60
|
+
token: token,
|
61
|
+
scheme: "header",
|
62
|
+
signature_method: nil,
|
63
|
+
nonce: nil,
|
64
|
+
timestamp: nil }.merge(options)
|
65
65
|
end
|
66
66
|
|
67
|
-
def oauth_full_request_uri(http,options)
|
68
|
-
uri = URI.parse(
|
67
|
+
def oauth_full_request_uri(http, options)
|
68
|
+
uri = URI.parse(path)
|
69
69
|
uri.host = http.address
|
70
70
|
uri.port = http.port
|
71
71
|
|
72
72
|
if options[:request_endpoint] && options[:site]
|
73
|
-
is_https = options[:site].match(%r
|
74
|
-
uri.host = options[:site].gsub(%r
|
73
|
+
is_https = options[:site].match(%r{^https://})
|
74
|
+
uri.host = options[:site].gsub(%r{^https?://}, "")
|
75
75
|
uri.port ||= is_https ? 443 : 80
|
76
76
|
end
|
77
77
|
|
78
|
-
if http.respond_to?(:use_ssl?) && http.use_ssl?
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
uri.scheme = if http.respond_to?(:use_ssl?) && http.use_ssl?
|
79
|
+
"https"
|
80
|
+
else
|
81
|
+
"http"
|
82
|
+
end
|
83
83
|
|
84
84
|
uri.to_s
|
85
85
|
end
|
@@ -89,7 +89,7 @@ private
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def set_oauth_header
|
92
|
-
self[
|
92
|
+
self["Authorization"] = @oauth_helper.header
|
93
93
|
end
|
94
94
|
|
95
95
|
# FIXME: if you're using a POST body and query string parameters, this method
|
@@ -100,19 +100,19 @@ private
|
|
100
100
|
# base string.
|
101
101
|
|
102
102
|
def set_oauth_body
|
103
|
-
|
104
|
-
params_with_sig = @oauth_helper.parameters.merge(:
|
105
|
-
|
103
|
+
set_form_data(@oauth_helper.stringify_keys(@oauth_helper.parameters_with_oauth))
|
104
|
+
params_with_sig = @oauth_helper.parameters.merge(oauth_signature: @oauth_helper.signature)
|
105
|
+
set_form_data(@oauth_helper.stringify_keys(params_with_sig))
|
106
106
|
end
|
107
107
|
|
108
108
|
def set_oauth_query_string
|
109
|
-
oauth_params_str = @oauth_helper.oauth_parameters.map { |k,v| [escape(k), escape(v)]
|
109
|
+
oauth_params_str = @oauth_helper.oauth_parameters.map { |k, v| [escape(k), escape(v)].join("=") }.join("&")
|
110
110
|
uri = URI.parse(path)
|
111
|
-
if uri.query.to_s == ""
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
111
|
+
uri.query = if uri.query.to_s == ""
|
112
|
+
oauth_params_str
|
113
|
+
else
|
114
|
+
uri.query + "&" + oauth_params_str
|
115
|
+
end
|
116
116
|
|
117
117
|
@path = uri.to_s
|
118
118
|
|