Action_back View All Articles

Google Apps & Ruby/Rails

Author: Ryan

November 2009

At MITA, we use Google Apps for email, and 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 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 * quota_limit_accounts * summary * suspended_accounts (described 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.use_ssl = true
    req = http.post('/hosted/services/v1.0/reports/ReportingData', xml_req)
    							
    							

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.