A Ruby GData access lib for Marketplace Vendor AppsPosted: June 16, 2010
Frustrated by oauth, the outdated gdata-ruby library, and experiencing general malaise about trying to plug your rails app into Google Enterprise Marketplace?
We’ve whipped up a small, simple convenience library to pull your Marketplace client’s data using oauth.
It’s released on Google Code as gdata-marketplace.
All you need to get started is:
- A Marketplace vendor account
- A test listing on Marketplace (you can use a “un-published” listing for testing)
- The Oauth consumer key and secret for the listed app (retrieved from the view listings page)
- An Google Apps account to test with
The library layers filters on the return data itself, so you can get raw stream access if you already have an XML solution, or you can use the included parse-to-OpenStruct layer. Finally, it implements a Memcache layer around the OpenStruct results.
The library does not have all the data hooks yet, but we will add to it as our integration expands (or until gdata-ruby is good alternative). Currently it is ideal for user and group provisioning (signup flow kinds of things). It also has calendar access. All access is currently pull (read-only).
Here’s an example:
# Example cached openstruct use:
# you can turn off cache by setting class var to nil, or
# by skipping the cache layer this way:
# m.data.users # basically, just insert .data in any request
m = GDataMarketplace::Client.new GOOGLE_CONSUMER_KEY, GOOGLE_CONSUMER_SECRET, 'firstname.lastname@example.org'
# or, if you don't care about default user identity:
# m = GDataMarketplace::Client.new GOOGLE_CONSUMER_KEY, GOOGLE_CONSUMER_SECRET, 'appsclient.com'
allusers = m.users
allgroups = m.groups
auser = m.user "someone"
agroup = m.group "agroupid"
agroup = m.group m.groups.first.groupId
agroupsmembers = m.group_members m.groups.first.groupId
# Example raw XML string access:
# turn off auto response parse
m.response_format = :net_http # will return the actual response object
# get request body
xmlstring = (m.request_user_provision :all).body # for all users
xmlstring = (m.request_user_provision "username").body # for a user
Let us know what you think!