Skip to content
This repository was archived by the owner on Mar 14, 2023. It is now read-only.

Commit afeb024

Browse files
author
jfisher
committed
started treating hash objects as HTTP form data. Cleaned up the clientlogin code to use this.
1 parent 4288e09 commit afeb024

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

lib/gdata/auth/clientlogin.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,15 @@ def initialize(service, options = {})
5757
# to a previously issued CAPTCHA challenge.
5858
def get_token(username, password, source, login_token = nil,
5959
login_captcha = nil)
60-
source = CGI.escape(source)
61-
password = CGI.escape(password)
62-
username = CGI.escape(username)
63-
body = "accountType=#{@account_type}&Email=#{username}" +
64-
"&Passwd=#{password}&service=#{@service}&source=#{source}"
60+
body = Hash.new
61+
body['accountType'] = @account_type
62+
body['Email'] = username
63+
body['Passwd'] = password
64+
body['service'] = @service
65+
body['source'] = source
6566
if login_token and login_captcha
66-
body += "&logintoken=#{login_token}&logincaptcha=#{login_captcha}"
67+
body['logintoken'] = login_token
68+
body['logincaptcha'] = login_captcha
6769
end
6870

6971
request = GData::HTTP::Request.new(@auth_url, :body => body,

lib/gdata/http/default_service.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ def make_request(request)
4747
raise ArgumentError, "Unsupported HTTP method specified."
4848
end
4949

50-
req.body = request.body
50+
case request.body
51+
when String
52+
req.body = request.body
53+
when Hash
54+
req.set_form_data(request.body)
55+
else
56+
req.body = request.body.to_s
57+
end
5158
request.headers.each do |key, value|
5259
req[key] = value
5360
end

0 commit comments

Comments
 (0)