I am trying to update CurrentLocation to Google Latitude using google-api-ruby-client.
I already have an access token, and refresh token which I obtained from mobile app and sent to by server on Ruby on Rails. The following is the code which I am trying to execute.
client = Google::APIClient.new(:key => gltoken)
client.authorization.client_id = '<my client id>'
client.authorization.client_secret = '<my client secret>'
client.authorization.access_token = "<the access token i ve>"
client.authorization.refresh_token = "<refresh token i ve>"
client.authorization.scope ='https://www.googleapis.com/auth/latitude.all.best https://www.googleapis.com/auth/latitude.current.best'
client.host = "www.googleapis.com"
latitudeapi = client.discovered_api('latitude', 'v1')
result = client.execute(
:api_method => 'latitude.currentLocation.insert',
:parameters => {
'kind' => 'latitude#location',
'latitude'=>37.420352,
'longitude'=>-122.083389,
'accuracy'=>130,
'altitude'=>35
}
)
logger.debug("Response #{result.body}")
result.body
I am getting the following result:
{"message":"{\"error\":{\"errors\":[{\"domain\":\"global\",\"reason\":\"invalid\",\"message\":\"Invalid Value\"}],\"code\":400,\"message\":\"Invalid Value\"}}"}
I am not able to find out which Value that I pass is invalid. I tried to update the same set of values as below to https://www.googleapis.com/latitude/v1/currentLocation?key= and it worked.
Header:
Content-Type: application/json
Authorization: Bearer <My access token>
Host: googleapis.com
Body:
{
"data": {
"kind":"latitude#location",
"latitude":37.420352,
"longitude":-122.083389,
"accuracy":130,
"altitude":35
}
}
Thanks in Advance.