From: "Jesús Gabriel y Galán" Date: 2007-10-09T00:48:36+09:00 Subject: Question about Mechanize and Google API Hi, I'm trying to use Mechanize to retrieve spreadsheets from Google Docs using the Google API. So far I got the ClientLogin to work, but I can't seem to be able to use the Auth token they give me back. This is what I have: require 'logger' require 'mechanize' agent = WWW::Mechanize.new {|a| a.log = Logger.new("test.log")} response = agent.post("https://www.google.com/accounts/ClientLogin", "Email" => "xxx@gmail.com", "Passwd" => "xxxxx", "service" => "wise", "source" => "personal-test-1.0", "accountType" => "GOOGLE") h = {} response.body.each {|line| a = line.split("="); h[a[0]] = a[1]} auth = h["Auth"] agent.basic_auth("GoogleLogin", auth) # this didn't work either #agent.auth("GoogleLogin", auth) page = agent.get("http://spreadsheets.google.com/feeds/spreadsheets/private/full") The problem is, according to google I have to: "After a successful authentication request, use the Auth value to create an Authorization header for each request: Authorization: GoogleLogin auth=yourAuthValue" I've checked and the ClientLogin is working and returning me an Auth token, but I can't get Mechanize to use it. In the Mechanize logs I see this: I, [2007-10-08T17:01:52.211778 #24929] INFO -- : Net::HTTP::Post: /accounts/ClientLogin D, [2007-10-08T17:01:52.394047 #24929] DEBUG -- : request-header: accept-language => en-us,en;q0.5 D, [2007-10-08T17:01:52.394214 #24929] DEBUG -- : request-header: connection => keep-alive D, [2007-10-08T17:01:52.394305 #24929] DEBUG -- : request-header: accept => */* D, [2007-10-08T17:01:52.394394 #24929] DEBUG -- : request-header: accept-encoding => gzip,identity D, [2007-10-08T17:01:52.394482 #24929] DEBUG -- : request-header: user-agent => WWW-Mechanize/0.6.10 (http://rubyforge.org/projects/mechanize/) D, [2007-10-08T17:01:52.394570 #24929] DEBUG -- : request-header: content-type => application/x-www-form-urlencoded D, [2007-10-08T17:01:52.394656 #24929] DEBUG -- : request-header: accept-charset => ISO-8859-1,utf-8;q=0.7,*;q=0.7 D, [2007-10-08T17:01:52.394742 #24929] DEBUG -- : request-header: content-length => 104 D, [2007-10-08T17:01:52.394828 #24929] DEBUG -- : request-header: keep-alive => 300 D, [2007-10-08T17:01:52.613138 #24929] DEBUG -- : Read 563 bytes D, [2007-10-08T17:01:52.613358 #24929] DEBUG -- : response-header: cache-control => no-cache D, [2007-10-08T17:01:52.613483 #24929] DEBUG -- : response-header: date => Mon, 08 Oct 2007 15:00:17 GMT D, [2007-10-08T17:01:52.613603 #24929] DEBUG -- : response-header: content-type => text/plain D, [2007-10-08T17:01:52.613721 #24929] DEBUG -- : response-header: server => GFE/1.3 D, [2007-10-08T17:01:52.613837 #24929] DEBUG -- : response-header: content-length => 563 D, [2007-10-08T17:01:52.613969 #24929] DEBUG -- : response-header: pragma => no-cache I, [2007-10-08T17:01:52.614363 #24929] INFO -- : status: 200 I, [2007-10-08T17:13:15.370472 #24929] INFO -- : Net::HTTP::Get: /feeds/spreadsheets/private/full D, [2007-10-08T17:13:15.482357 #24929] DEBUG -- : request-header: accept-language => en-us,en;q0.5 D, [2007-10-08T17:13:15.482481 #24929] DEBUG -- : request-header: connection => keep-alive D, [2007-10-08T17:13:15.482534 #24929] DEBUG -- : request-header: accept => */* D, [2007-10-08T17:13:15.482587 #24929] DEBUG -- : request-header: accept-encoding => gzip,identity D, [2007-10-08T17:13:15.482639 #24929] DEBUG -- : request-header: user-agent => WWW-Mechanize/0.6.10 (http://rubyforge.org/projects/mechanize/) D, [2007-10-08T17:13:15.482692 #24929] DEBUG -- : request-header: referer => https://www.google.com/accounts/ClientLogin D, [2007-10-08T17:13:15.482745 #24929] DEBUG -- : request-header: accept-charset => ISO-8859-1,utf-8;q=0.7,*;q=0.7 D, [2007-10-08T17:13:15.482796 #24929] DEBUG -- : request-header: keep-alive => 300 D, [2007-10-08T17:13:15.652098 #24929] DEBUG -- : Read 141 bytes D, [2007-10-08T17:13:15.652313 #24929] DEBUG -- : response-header: cache-control => no-cache, no-store, max-age=0, must-revalidate D, [2007-10-08T17:13:15.652438 #24929] DEBUG -- : response-header: expires => Fri, 01 Jan 1990 00:00:00 GMT D, [2007-10-08T17:13:15.652604 #24929] DEBUG -- : response-header: date => Mon, 08 Oct 2007 15:11:40 GMT D, [2007-10-08T17:13:15.652725 #24929] DEBUG -- : response-header: content-type => text/html; charset=UTF-8 D, [2007-10-08T17:13:15.652859 #24929] DEBUG -- : response-header: www-authenticate => No credentials were included in your request. D, [2007-10-08T17:13:15.652977 #24929] DEBUG -- : response-header: server => GFE/1.3 D, [2007-10-08T17:13:15.653094 #24929] DEBUG -- : response-header: set-cookie => S=trix=Xc7oom0LVJ8; Path=/ D, [2007-10-08T17:13:15.653211 #24929] DEBUG -- : response-header: content-length => 141 D, [2007-10-08T17:13:15.653326 #24929] DEBUG -- : response-header: pragma => no-cache D, [2007-10-08T17:13:15.659559 #24929] DEBUG -- : saved cookie: S=trix=Xc7oom0LVJ8 I, [2007-10-08T17:13:15.659765 #24929] INFO -- : status: 404 So, it seems that the credentials are not correctly set. Anybody knows how to do this? Thanks, Jesus.