views:

5

answers:

0

I'm trying to retrieve the list of documents (from Google Docs) as an XML feed via ruby's net/http. So getting an AuthSub token works pretty well, then the issues begin... No matter what I'm trying, I'll always get Token invalid - Invalid AuthSub token as a response.

First of all, I'm requesting the AuthSub login stuff in the browser via:

= link_to "Try again!", "https://www.google.com/accounts/AuthSubRequest?scope=#{URI.escape('https://docs.google.com/feeds')}&next=#{URI.escape(gdocs_url)}"

Whereby gdocs_url is my next-callback, which then looks like (PS: yes, it's a rails app):

def gdocs
  uri = URI.parse("https://docs.google.com/feeds/default/private/full")
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  @gdocs_request = Net::HTTP::Get.new(uri.request_uri, {
              'gdata-version' => '3.0',
              'authorization' => 'AuthSub token="' + params[:token] + '"' })
  @gdocs_response = http.request(@gdocs_request)
end

The request headers sent by net/http are:

accept: */*
connection: close
authorization: AuthSub token="1/z3PtNRaXXXXXXXXXXXXXXXXXXXXXXXX"
gdata-version: 3.0
host: docs.google.com

And yeah, I verified if the ?token=.... matches the header and it does - also checked the ZEND GData PHP source if maybe I've to URL encode the token or anything like that, but no pointers there. Just not sure what I'm doing wrong exactly.

Also tried to request it via CURL (after getting a new token):

curl -H 'Authorization: AuthSub token="1/p4NazXXXXXXXXXXXXXXXXXXXXXXXXXXX"' \
     'https://docs.google.com/feeds/default/private/full'

to no avail, any ideas or pointers? My output always looks like:

<HTML>
<HEAD>
<TITLE>Token invalid - Invalid AuthSub token.</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Token invalid - Invalid AuthSub token.</H1>
<H2>Error 401</H2>
</BODY>
</HTML>

PS: I know GDocs API 3.0 is in "labs", but get the same error with 2.0 so... PPS: I also have tried setting session=1 when requesting the token, no luck. Btw - I don't want a session token, single access is fine.