lib/tumblr/request/oauth.rb in tumblr_client-0.6.9 vs lib/tumblr/request/oauth.rb in tumblr_client-0.6.11
- old
+ new
@@ -19,11 +19,11 @@
params.each do |key, value|
signature_params = {} if value.respond_to?(:content_type)
end
env[:request_headers]["Authorization"] = self.oauth_gen(env[:method], url, signature_params)
env[:request_headers]["Content-type"] = "application/x-www-form-urlencoded"
- env[:request_headers]["Host"] = "api.tumblr.com"
+ env[:request_headers]["Host"] = @options[:api_host]
@app.call(env)
end
@@ -31,10 +31,10 @@
@app, @options = app, options
end
def oauth_gen(method, url, params)
params[:oauth_consumer_key] = @options[:consumer_key]
- params[:oauth_nonce] = Time.now.to_i
+ params[:oauth_nonce] = Base64.encode64(OpenSSL::Random.random_bytes(32)).gsub(/\W/, '')
params[:oauth_signature_method] = 'HMAC-SHA1'
params[:oauth_timestamp] = Time.now.to_i
params[:oauth_token] = @options[:token]
params[:oauth_version] = "1.0"
params[:oauth_signature] = self.oauth_sig(method, url, params)