Two Legged OAuth
For more info on the 2 legged OAuth see these :
- Google Apps OAuth
- 2 Legged OAuth in PHP
- Google Apps Marketplace Authentication Best Practices
- Google Data APIs 2 Legged OAuth
This gem has been tested with the following libraries so far and seems to be working ok :
- GoogleSpreadsheet (with some custom fixes that hopefully will get integrated to the official gem)
- Google Apps Marketplace Ruby tutorial
Add on your Gemfile :
On the console :
gem install two-legged-oauth
On your code :
# 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@example.com") # Pass that access token to Google Data libraries (or your custom scripts) gs = GoogleSpreadsheet.login_with_oauth(access_token)
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...
Report any issues on the github's issue tracker or send a pull request if you have nailed the bug.
Tested contributions are always welcome! Here's what you should do:
- Clone the repo
- Run the tests
- Write some test-driven code
- Create a pull request
two-legged-oauth is copyright 2011 by Fraudpointer, released under the MIT License (see LICENSE for details).