ryanwold.net

A civic-minded citizen seeking the singularity

An entry

Google Apps & Ruby/Rails

Date: 2009-11-17
Status: release
Tags: api google ruby integration

At MITA, we used Google Apps for email, online documents, spreadsheets, forms, chat, and more.
I've been weaving Applications together in an Intranet, using Ruby & Rails.
Ruby is a pleasure to work with. It is a logical, flexible, and powerful object-oriented scripting-type language. The "Staff Listing" on the Intranet list the 50+ employees in the organization, and the data is pulled from PowerSchool, the school's Student Information System (SIS) [where all Employees are centrally managed anyway].

Using Ruby and Google's API, I've put together the following pages:

  • Index
  • Login

Using a webform, submit Google login information (username and password) to https://www.google.com/accounts/ClientLogin , which returns the "token":

SID=DQAAAIUAAAAfSngN...
LSID=DQAAAIcAAAAinnV...
Auth=DQAAAIcAAAAinnV...
  • Reports
    The "Reports" page uses the SID from the token, and submits a request to google.com/hosted/services/v1.0/reports/ReportingData. Using Google's API, I can grab * accounts

  • activity

  • disk_space

  • email_clients

  • quotalimitaccounts

  • summary

  • suspendedaccounts (described <a href="http://code.google.com/apis/apps/reporting/googleappsreportingapi.html">here)

    @token = SID @domain = your Google Apps domain name (this assumes you are using Google Apps for your domain)
    @date = "2009-11-14"

    This XML String will be posted to the URL below

    xml_req =< Report #{@token} @domain @date daily accounts EOF

    This actually posts the Request

    http = Net::HTTP.new('www.google.com', 443) http.usessl = true req = http.post('/hosted/services/v1.0/reports/ReportingData', xmlreq)

I've also touched the surface pulling feeds from the domain, using google.com/a/feeds/domain_name - this is something to explore a bit more.