require 'net/http' require 'net/https' require 'cgi' require 'rubygems' require 'xmlsimple' require 'pp' def get_feed(uri, headers=nil) uri = URI.parse(uri) Net::HTTP.start(uri.host, uri.port) do |http| return http.get(uri.path, headers) end end email = '[email protected]' password = CGI::escape('pa$$word') service = 'writely' source = 'MyCompany-MyApp-0.1' path = '/accounts/ClientLogin' data = ["accountType=HOSTED_OR_GOOGLE", "Email=#{email}", "Passwd=#{password}", "service=#{service}", "source=#{source}"].join('&') http = Net::HTTP.new(host='www.google.com', port=443) http.use_ssl = true http.start headers = {'Content-Type' => 'application/x-www-form-urlencoded'} resp, data = http.post(path, data, headers) token = data[/Auth=(.*)/, 1] # parse out the Auth token headers['Authorization'] = "GoogleLogin auth=#{token}" resp = get_feed('http://docs.google.com/feeds/documents/private/full', headers) doc = XmlSimple.xml_in(resp.body, 'KeyAttr' => 'name') pp doc
Showing posts with label ClientLogin. Show all posts
Showing posts with label ClientLogin. Show all posts
Accessing a feed using ClientLogin & Ruby
Posted by
Eric (Google)
on
Friday, November 14, 2008
Example of accessing the DocList API using ClientLogin in Ruby:
Labels:
ClientLogin,
DocList,
ruby
Force PHP to use a Google Account in ClientLogin
Posted by
Jeff Fisher
on
Friday, October 31, 2008
Sometimes you have a Google Apps account that is also registered as a Google Account and you want to make sure you are logging in as the Google Account, especially when you want to use a service like Picasa Web Albums that does not have an Apps version.
To do this using ClientLogin you need to do something like:
$serviceName = Zend_Gdata_Photos::AUTH_SERVICE_NAME; $username = "[email protected]"; $pass = "password"; $accountType = "GOOGLE"; $client = Zend_Gdata_ClientLogin::getHttpClient($username, $pass, $serviceName, null, Zend_Gdata_ClientLogin::DEFAULT_SOURCE, null, null, Zend_Gdata_ClientLogin::CLIENTLOGIN_URI, $accountType);
Labels:
ClientLogin,
php
Perform ClientLogin using curl
Posted by
Jeff Scudder
on
Monday, August 04, 2008
Requests an authorization token for one of the Google Data API services and stores it in the shell environment variable
GDATA_AUTH
. This shell script takes three command line parameters, the email address for the desired account, password, and the service name of the service which the token will be used to access.#!/bin/sh export GDATA_AUTH=`curl 2>/dev/null https://www.google.com/accounts/ClientLogin \ -d Email=$1 -d Passwd=$2 -d accountType=HOSTED_OR_GOOGLE -d source=curlExample \ -d service=$3 | grep '^Auth=' | cut -c 6-` echo $GDATA_AUTH
Labels:
ClientLogin,
curl
Subscribe to:
Posts (Atom)