Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.
mislav edited this page Sep 12, 2010 · 5 revisions

Web applications should use AuthSub proxy authentication to get an authentication token for a Google account.

First, get the user to follow the following URL:

Contacts::Gmail.authentication_url('http://mysite.com/invite')

After he authenticates successfully, Google will redirect him back to the target URL (specified as argument above) and provide the token GET parameter. Use it to create a new instance of this class and request the contact list:

gmail = Contacts::Gmail.new('[email protected]', params[:token])
contacts = gmail.contacts
#-> [ ['Fitzgerald', '[email protected]', '[email protected]'],
      ['William Paginate', '[email protected]'], ...
      ]

Various parameters

Contacts::Gmail.authentication_url(target, options = {})
  • :scope — the AuthSub scope in which the resulting token is valid (default: http://www.google.com/m8/feeds/)
  • :secure — boolean indicating whether the token will be secure (default: false)
  • :session — boolean indicating if the token can be exchanged for a session token (default: false)
Contacts::Gmail.new(email, token, options = {})
  • :limit — use a large number to fetch a bigger contact list (default: 200)
  • :offset — 0-based value, can be used for pagination
  • :order — currently the only value support by Google is "lastmodified"
  • :descending — boolean
  • :updated_after — string or time-like object, use to only fetch contacts that were updated after this date
Clone this wiki locally