How do you Access an Authenticated Google App Engine Service with Ruby?

Posted by viatropos on Stack Overflow See other posts from Stack Overflow or by viatropos
Published on 2010-04-11T00:42:25Z Indexed on 2010/04/11 0:53 UTC
Read the original article Hit count: 455

I am trying to do this same thing here but with Ruby: Access Authenticated GAE Client with Python. Any ideas how to retrieve authenticated content from GAE with Ruby?

I am using the Ruby GData Gem to access everything in Google Docs and such and it's making life very easy, but now I'd like to access things on GAE that require admin access, programmatically, and it doesn't support that.

Here's what I'm getting (using DocList, not sure what to use yet):

c = GData::Client::DocList.new
c.clientlogin(username, password, nil, nil, nil, "HOSTED")
c
=> #<GData::Client::DocList:0x201bad8 @clientlogin_service="writely", @version="2",
  @auth_handler=#<GData::Auth::ClientLogin:0x200803c @account_type="HOSTED",
  @token="long-hash", @auth_url="https://www.google.com/accounts/ClientLogin",
  @service="writely">, @source="AnonymousApp", @headers={"Authorization"=>"GoogleLogin
  auth=long-hash", "User-Agent"=>"GoogleDataRubyUtil-AnonymousApp",
  "GData-Version"=>"2", "Content-Type"=>"application/atom+xml"},
  @authsub_scope="http://docs.google.com/feeds/",
  @http_service=GData::HTTP::DefaultService>

url = "http://my-cdn.appspot.com/files/restricted-file.html"
c.get(url)
=> #<GData::HTTP::Response:0x20004b8 @status_code=302, @body="",
  @headers={"connection"=>"close", "date"=>"Sun, 11 Apr 2010 00:30:20 GMT",
  "content-type"=>"text/html", "server"=>"Google Frontend", "content-length"=>"0",
  "location"=>"https://www.google.com/accounts/ServiceLogin
  service=ah&continue=http://my-cdn.appspot.com/_ah/login%3Fcontinue%3D
  http://my-cdn.appspot.com/files/restricted-file.html&
  ltmpl=gm&ahname=My+CDN&sig=a-signature"}>

Any tips? That other SO question pointed to doing something with the redirect... Not sure how to handle that.

Just looking for a point in the right direction from the ruby experts. Thanks.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about google-app-engine