ip2k / google-api-ruby-client

Automatically exported from code.google.com/p/google-api-ruby-client
Apache License 2.0
0 stars 0 forks source link

Parameters not urlencoded (cause 400 error) #31

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. instaniate google calendar client
2. request events changed since some close date (updatedMin paramater)
ex code: 
  client_id     = '<<CLIENT_ID>>'
  client_secret = '<<CLIENT_SECRET>>'
  refresh_token = '<<REFRESH_TOKEN>>'
  calendar_id   = '<<>CALENDAR_ID, such a user@domain.com>'
  client = Google::APIClient.new
  client.authorization.client_id = client_id
  client.authorization.client_secret = client_secret
  client.authorization.scope = 'https://www.googleapis.com/auth/calendar'
  client.authorization.redirect_uri = 'https://redirect.uri/here'
  client.authorization.refresh_token = refresh_token
  client.authorization.fetch_access_token!
  calendar = client.discovered_api('calendar', 'v3')
  params = {}
  # this string cause error in result
  params['updatedMin'] = '2012-01-01T17:17:20+00:00'
  params['calendarId'] = calendar_id
  result = client.execute(:api_method => calendar.events.list, :parameters => params)
  puts result.response.inspect

400 code returned

What is the expected output? What do you see instead?
Expect call successed (200 code returned and data) 

What version of the product are you using? On what operating system?
ruby 1.8.7, google-api-client-0.3.0

Please provide any additional information below.
After researching I'v discovered that library doesn't handle parameters 
encoding. In particular '2012-01-01T17:17:20+00:00' shoul have : and + signs 
encoded (Google API explorer do).
Also, i'v discovered that no parameters encoded at all, such a free-text query.
Patch proivided force to urlencode all parameters in request, and works well.

Original issue reported on code.google.com by nikolay....@absalt.com on 7 Jan 2012 at 8:26

Attachments:

GoogleCodeExporter commented 9 years ago
Could you please sign the Google CLA (electronic signature is fine) since this 
is a patch? Ping this issue when you're done.

http://code.google.com/legal/individual-cla-v1.0.html

Original comment by bobaman@google.com on 10 Jan 2012 at 7:44

GoogleCodeExporter commented 9 years ago

Original comment by bobaman@google.com on 10 Jan 2012 at 7:44

GoogleCodeExporter commented 9 years ago
I'v sign CLA (electronically), what should I do?

Original comment by nikolay....@absalt.com on 13 Jan 2012 at 9:00

GoogleCodeExporter commented 9 years ago
Thanks. You're all set. I'll get this committed soon.

Original comment by bobaman@google.com on 13 Jan 2012 at 9:09

GoogleCodeExporter commented 9 years ago
Is this fix in already? Latest log doesn't seem to show so.

Original comment by aoe...@gmail.com on 15 Feb 2012 at 1:04

GoogleCodeExporter commented 9 years ago
Sorry, mentally checked this one off as resolved, but didn't ever get around to 
calling 'git apply'. It's committed and pushed now.

Original comment by bobaman@google.com on 15 Feb 2012 at 1:27