Created
August 5, 2015 14:48
-
-
Save maaand/faa7414ff167815c1105 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.generate_oauth_signature | |
# Capture all oauth parameters, percent encode them, and create the parameter_string. | |
oauth_consumer_key = '163'#290' | |
logger.info "Consumer Key : #{oauth_consumer_key}" | |
oauth_nonce = Digest::MD5.hexdigest(Time.now.to_s + rand(1..100).to_s)[0..5]#"3FC01D14-BD45-4940-BD78-1FC3F03CC11A" | |
logger.info "Nonce : #{oauth_nonce.to_s}" | |
oauth_signature_method = "HMAC-SHA1" | |
logger.info "Signature Method : #{oauth_signature_method}" | |
oauth_timestamp = Time.now.to_i# "1435622860" | |
logger.info "Timestamp : #{oauth_timestamp}" | |
oauth_version = "1.0" | |
logger.info "Version : #{oauth_version}" | |
# add = "[1815]" | |
# logger.info "Add: #{add}" | |
encoded_oauth_consumer_key = url_encode(oauth_consumer_key) | |
encoded_oauth_nonce = url_encode(oauth_nonce) | |
encoded_oauth_signature_method = url_encode(oauth_signature_method) | |
encoded_oauth_timestamp = url_encode(oauth_timestamp) | |
encoded_oauth_version = url_encode(oauth_version) | |
# encoded_add = url_encode(add) | |
# Recipe = ADD=[1815] | |
parameter_string = "oauth_consumer_key=#{encoded_oauth_consumer_key}&oauth_nonce=#{encoded_oauth_nonce}&oauth_signature_method=#{encoded_oauth_signature_method}&oauth_timestamp=#{encoded_oauth_timestamp}&oauth_version=#{encoded_oauth_version}" | |
logger.info "Paramter String: #{parameter_string}" | |
encoded_parameter_string = url_encode(parameter_string) | |
# Capture and format http verb | |
http_verb = "GET" | |
# http_verb = "GET" | |
encoded_verb = http_verb.upcase |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment