PackageDescription: GData

G Data

Last published: September 14, 2007 by 'jamesr'

Defines 2 Classes
Extends 2 Classes

Implements a minimal part of the GData API as an example.

Here's the workspace script used in the screencasts (provide your own username and password)

username := 'put your Google email address here'.
password := 'put your Google password here'.

encoding := 'application/x-www-form-urlencoded'.
url := ''.
stream := WriteStream on: String new.
stream nextPutAll: 'Email=', (OS.URI encode: username).
stream nextPutAll: '&Passwd=', (OS.URI encode: password).
stream nextPutAll: '&source=', (OS.URI encode: 'cincom-exampleCalendarApp').
stream nextPutAll: '&service=cl'.
request := HttpRequest post: url.
request contentType: encoding.
request contents: stream contents.

client := HttpClient new.
response := [client executeRequest: request]
on: Security.SSLBadCertificate
do: [:ex | ex resume].

authStream := response contents readStream.
authStream through: $=.
sid := authStream upToAll: 'LSID='.
authStream through: $=.
lsid := authStream upToAll: 'Auth='.
authStream through: $=.
auth := authStream upToEnd.
auth := auth copyWithout: Character lf.

request2 := HttpRequest get: ''.
field := AuthorizationField new.
val := field addScheme: 'GoogleLogin'.
val data: 'auth=', auth.
request2 fieldAt: 'authorization' put: field.

client := HttpClient new.
client authPolicy: GDataAuthenticationPolicy new.
client authPolicy authentication: field.
client authPolicy googleAuth: field.
response2 := [client executeRequest: request2]
on: Security.SSLBadCertificate
do: [:ex | ex resume].

calFeedString := response2 contents.
calFeed := Constructor getFeedFromStream: calFeedString readStream