Autopen is a Ruby gem that writes your (OAuth) signatures for you.
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.gitignore
Gemfile
LICENSE
README.md
Rakefile
autopen.gemspec

README.md

Code Climate

Autopen

Autopen writes your (OAuth) signatures for you. That's all it does. Simple.

Installation

Add this line to your application's Gemfile:

gem 'autopen'

And then execute:

$ bundle

Or install it yourself as:

$ gem install autopen

Usage

require 'autopen'
signature = Autopen::Signature.new(HTTP METHOD, URL, POST_PARAMS, {:consumer_key => "YOUR CONSUMER KEY", :consumer_secret => "YOUR CONSUMER SECRET", :version => "1.0 (probably)", :timestamp => Time.now.to_i, :nonce => "YOUR NONCE HERE", :token => "YOUR TOKEN, IF YOU HAVE ONE. OTHERWISE DON'T INCLUDE THIS VALUE AT ALL.", :token_secret => "YOUR TOKEN SECRET, IF YOU HAVE ONE. OTHERWISE DON'T INCLUDE THIS VALUE AT ALL."})
request_signature = s.generate

That's a little... generic, so let's try an example. To generate the signature the Twitter API example documented here and here, do this:

require 'autopen'
s = Autopen::Signature.new("post", "https://api.twitter.com/1/statuses/update.json?include_entities=true", {"status" => "Hello Ladies + Gentlemen, a signed OAuth request!"}, {:consumer_key => "xvz1evFS4wEEPTGEFPHBog", :consumer_secret => "kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw", :version => "1.0", :timestamp => 1318622958, :nonce => "kYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg", :token => "370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb", :token_secret => "LswwdoUaIvS8ltyTt5jkRh4J50vUPVVHtR2YPi5kE"})
request_signature = s.generate # returns "tnnArxj06cWHq44gCs1OSKk%2FjLY%3D"

There's two other methods on an Autopen::Signature that might be useful. One is oauth_params, which will return an alphabetized Hash of all the OAuth params. The other is url, which will return the url you entered along with the OAuth params.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request