muck-oauth
This gem wraps oauth and oauth-plugin to make it simple to get tokens for services that muck can interact with various services.
For more documentation see: github.com/pelle/oauth-plugin stakeventures.com/articles/2009/07/21/consuming-oauth-intelligently-in-rails stakeventures.com/articles/2008/02/23/developing-oauth-clients-in-ruby
Installation
Add the following to environment.rb
config.gem "oauth"
config.gem "oauth-plugin"
config.gem "muck-oauth"
Add the following to your user model:
acts_as_muck_oauth_user
Configuration
Add the following to global_config.yml. Be sure to get keys from each service that you want to interact with.
# Oauth
# Twitter api access: http://www.twitter.com/apps
twitter_oauth_key: ''
twitter_oauth_secret: ''
# Google api access: http://code.google.com/apis/accounts/docs/RegistrationForWebAppsAuto.html#register
google_oauth_key: ""
google_oauth_secret: ""
# Yahoo api access: http://developer.yahoo.com/flickr/
yahoo_oauth_key: ""
yahoo_oauth_secret: ""
# Flick api access: http://www.flickr.com/services/apps/create/apply
# flickr_oauth_key:
# flickr_oauth_secret:
# Linked In api access: https://www.linkedin.com/secure/developer
# linkedin_oauth_key: ""
# linkedin_oauth_secret: ""
linkedin_oauth_key: ""
linkedin_oauth_secret: ""
# Friendfeed api access: https://friendfeed.com/account/login?next=%2Fapi%2Fregister
# Production
friendfeed_oauth_key: ''
friendfeed_oauth_secret: ''
# Test
friendfeed_oauth_key: ''
friendfeed_oauth_secret: ''
Usage
Add configuration for services to:
intializers/oauth_consumers.rb
Link to each service like this:
<a href="/oauth_consumers/twitter">Twitter</a>
<a href="/oauth_consumers/google">Google</a>
Each service provides methods that enable communication with the service’s api via popular gems. For example, the twitter service uses the twitter gem and so you can call methods against a user’s twitter account like this:
user.twitter.client.verify_credentials[:screen_name]
Please see each gem’s documentation for more information: Twitter Docs: rdoc.info/projects/jnunemaker/twitter Twitter Examples: github.com/jnunemaker/twitter-app/ i.e.
user.twitter.client
Linked In Docs: github.com/pengwynn/linkedin i.e.
user.linked_in.client
Google Docs: github.com/pelle/portablecontacts i.e.
user.google.portable_contacts
Fire Eagle Docs: fireeagle.rubyforge.org/ i.e.
user.fire_eagle.client
Friend Feed Docs: None yet
Yahoo Docs: None yet
Flickr None yet
Tips and Help
If you get an error like this:
uninitialized constant User::TwitterToken
it means you need to setup your global_config.yml with the values specified above.
Copyright © 2009 Tatemae.com. See LICENSE for details.