Method: Google::Base#login
- Defined in:
- lib/google/base.rb
#login ⇒ Object
Makes authentication request to google and sets the sid to be passed in a cookie with each authenticated request.
Raises Google::LoginError if login is unsuccessful
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/google/base.rb', line 95 def login url = URI.parse(LOGIN_URL) req = Net::HTTP::Post.new(url.request_uri) req.set_form_data({ 'accountType' => 'HOSTED_OR_GOOGLE', 'Email' => @email, 'Passwd' => @password, 'source' => SOURCE, 'continue' => URL, }) http = Net::HTTP.new(url.host, url.port) http.use_ssl = true result = http.start() { |conn| conn.request(req) } @sid = extract_sid(result.body) raise LoginError, "Most likely your username and password are wrong." unless logged_in? end |