Skip to content

Instantly share code, notes, and snippets.

@ukstudio
Created February 3, 2010 21:28
Show Gist options
  • Select an option

  • Save ukstudio/294044 to your computer and use it in GitHub Desktop.

Select an option

Save ukstudio/294044 to your computer and use it in GitHub Desktop.
# coding: utf-8
require 'rubygems'
require 'net/https'
require 'net/http'
require 'rack'
email = Rack::Utils.escape('your google account mail address')
password = Rack::Utils.escape('your google account password')
service = 'local'
source = 'corp-app-0.1'
path = '/accounts/ClientLogin'
data = ["accountType=HOSTED_OR_GOOGLE",
"Email=#{email}",
"Passwd=#{password}",
"service=#{service}",
"source=#{source}"].join('&')
http = Net::HTTP.new('www.google.com', 443)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
token = ''
headers = {'Content-Type' => 'application/x-www-form-urlencoded'}
http.start do |http|
response,body = http.post(path, data, headers)
token = body[/Auth=(.*)/, 1]
end
headers['Authorization'] = "GoogleLogin auth=#{token}"
uri = URI.parse('http://maps.google.com/maps/feeds/maps/default/full')
Net::HTTP.start(uri.host, uri.port) do |http|
resp = http.get(uri.path, headers)
p resp.body
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment