Crazylegs - the hacky 2-legged OAuth Library

Author

Dave Copeland ([email protected])

Copyright

Copyright © 2011 by Dave Copeland

License

Distributes under the Apache License, see LICENSE.txt in the source distro

Crazylegs is a very small library to sign urls for two-legged OAuth. This will not request urls for you, it will not parse a response for you, it will not give you some crazy DSL to abstract away the details. It will properly sign a URL using a consumer key and secret so that you can make an OAuth request for 2-legged auth. That’s it.

Use

Install if you need to:

gem install crazylegs

Example

include Crazylegs
credentials = Credentials.new(consumer_key,shared_secret)
url = SignedURL.new(credentials,"http://api.example.com/api/customers",'GET')
url['accountNumber'] = '655321'
signed_url = url.full_url
# signed_url can now be requested of the remote server

# If you want to use the header-based version
url = SignedURL.new(credentials,"http://api.example.com/api/customers/12/address",'POST')
signed_url,headers = url.full_url_using_headers
# Now, you can POST signed_url as long as you included headers in your HTTP request

See Crazylegs::SignedURL and Crazylegs::Credentials for more info.

Seeing WTF is going on

logger = Logger.new(STDERR)
logger.level = Logger::DEBUG
url = SignedURL.new(credentials,"http://scrapi-demo-dev.opower.com/api/customers",'GET',logger)