Skip to content

Instantly share code, notes, and snippets.

@rivernate
Created March 9, 2016 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rivernate/a2ef2c18d3ecb34029da to your computer and use it in GitHub Desktop.
Save rivernate/a2ef2c18d3ecb34029da to your computer and use it in GitHub Desktop.
require 'simple_oauth'
SimpleOAuth::Header::ATTRIBUTE_KEYS << :body_hash unless SimpleOAuth::Header::ATTRIBUTE_KEYS.include? :body_hash
def self.validate(header, url, secret)
o = SimpleOAuth::Header.new(:post, url, {}, SimpleOAuth::Header.parse(header).merge({consumer_secret: secret}))
puts o.send(:signature)
puts o.send(:signature_base)
#puts o.send(:secret)
puts o.valid?()
o
end
@rivernate
Copy link
Author

this is using the simple_oauth 0.2.0 version

@rivernate
Copy link
Author

sample call:
validate(
'OAuth oauth_body_hash="Bxm2wNURamGzegzEERiM44CxC5I%3D", oauth_signature_method="HMAC-SHA1", oauth_nonce="C492D22B-0A06-0894-6824-2E51BB2D2F97", oauth_consumer_key="mKes4fd", oauth_timestamp="17337600", oauth_version="1.0", oauth_signature="F8EuLjA3kfH+WcwQ4bisxmUsfpU="',
'https://canvas.instructure.com/test/42',
'shhh'
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment