Permalink
Browse files

Removed debug

  • Loading branch information...
1 parent b61213a commit 448d4e3cc7b5f21c23d8ad308c0b99f3a287cdae @matsumotory committed Jan 1, 2013
Showing with 1 addition and 14 deletions.
  1. +1 −14 mrblib/oauth.rb
View
@@ -1,4 +1,5 @@
class OAuth < HttpRequest
+ OAUTH_VERSION = '1.0'
VERSION = '0.1'
USER_AGENT = "mruby_oauth/" + VERSION
def initialize(consumer_key, consumer_secret, token, token_secret)
@@ -22,17 +23,12 @@ def request(method, url, body = nil, headers = {})
request['Authorization'] = auth_header(method, url, request["body"])
request['User-Agent'] = USER_AGENT
host = url.host.to_sym.to_s
- p method, request_uri, request
SimpleHttp.new(host, url.port).request(method, request_uri, request)
end
def auth_header(method, url, body)
parameters = oauth_parameters
parameters["oauth_signature"] = signature(method, url, body, parameters)
- p 'OAuth ' + encode_parameters(parameters, ', ', '"')
end
-
- OAUTH_VERSION = '1.0'
-
def oauth_parameters
{
"oauth_consumer_key" => @consumer_key,
@@ -48,20 +44,16 @@ def timestamp
end
def nonce
Digest::MD5.hexdigest(timestamp)
- #MD5::md5_hex(timestamp)
end
def signature(*args)
base64(digest_hmac_sha1(signature_base_string(*args)))
end
def base64(value)
- # [ value ].pack('m').gsub(/\n/, '')
r = [ value ].pack('m')
r.include?("\n") ? r.split("\n").join("") : r
end
def digest_hmac_sha1(value)
Digest::HMAC.digest(value, secret, Digest::SHA1)
- #h.digest
- #SHA1::sha1_hex(value)
end
def secret
escape(@consumer_secret) + '&' + escape(@token_secret)
@@ -70,17 +62,12 @@ def signature_base_string(method, url, body, parameters)
method = method.upcase
base_url = signature_base_url(url)
parameters = normalize_parameters(parameters, body, url.query)
- p ['signature_base_string', method, base_url, parameters]
- p encode_parameters([ method, base_url, parameters ])
end
def signature_base_url(url)
str = url.schema + "://"
- #str += url.userinfo + "@" if url.userinfo
str += url.host
str += ":" + url.port if url.port
str += url.path if url.path
- #str += "?" + url.query if url.query
- p ["sigbature_base_url", str]
str
end
def normalize_parameters(parameters, body, query)

0 comments on commit 448d4e3

Please sign in to comment.