Two Legged OAuth

Description

The purpose of this gem is to make the oauth gem play nice with Google's custom 2 legged OAuth (2LO), used specifically for Google Apps APIs accessed from Google Apps Marketplace applications.

For more info on the 2 legged OAuth see these :

This gem has been tested with the following libraries so far and seems to be working ok :

Installation

Bundler

Add on your Gemfile :

gem 'two-legged-oauth'

By hand

On the console :

gem install two-legged-oauth

On your code :

require 'two-legged-oauth'

Usage

# Create a normal consumer instance
oauth_consumer = OAuth::Consumer.new("key", "secret")

# Initialize a TwoLeggedAccessToken specifying the xoauth_requestor_id
access_token = OAuth::TwoLeggedAccessToken.new(oauth_consumer, "[email protected]")

# Pass that access token to Google Data libraries (or your custom scripts)
gs = GoogleSpreadsheet.(access_token)

Internals

This thing works by rewriting the requested URL on-the-fly and appends the xoauth_requestor_id param appropriately. This may be dangerous at times so be aware that some well hidden bugs may come up...

Bugs/fixes

Report any issues on the github's issue tracker or send a pull request if you have nailed the bug.

Contributing

Tested contributions are always welcome! Here's what you should do:

  1. Clone the repo
  2. Run the tests
  3. Write some test-driven code
  4. Create a pull request

License

two-legged-oauth is copyright 2011 by Fraudpointer, released under the MIT License (see LICENSE for details).