Not with this particular issue, but we ran into something similar when
someone's access token has expired. The problem was, that the HTTParty
response code was 400 but it contained an OAuthException which never
got properly raised (HTTPException got raised instead).
# Log
------------- Mogli::Client::HTTPException -------------
Wed Aug 31 14:49:26 +0200 2011
data.code: 400
#<HTTParty::Response:0xa03a570
@parsed_response={"error"=>{"type"=>"OAuthException",
"message"=>"Error validating access
token: Session has expired at unix time 1314788400. The current unix
time is 1314794966."}}, @response=#
<Net::HTTPBadRequest 400 Bad Request readbody=true>,
@headers={"expires"=>["Sat, 01 Jan 2000 00:00:00 GMT"], "p3p"=>
["CP=\"Facebook does not have a P3P policy. Learn why here:
http://fb.me/p3p\""],
"content-type"=>["text/javascript;
charset=UTF-8"], "connection"=>["close"], "www-authenticate"=>["OAuth
\"Facebook Platform\" \"invalid_token\" \"Error
validating access token: Session has expired at unix time 1314788400.
The current unix time is 1314794966.\""], "date"=>
["Wed, 31 Aug 2011 12:49:26 GMT"], "content-length"=>["160"], "set-
cookie"=>["datr=1i1eTijMMNsbHmmxZi-oicp1; expires=Fri,
30-Aug-2013 12:49:26 GMT; path=/; domain=.
facebook.com; httponly"],
"cache-control"=>["no-store"], "x-fb-rev"=>["432627"],
"x-fb-server"=>["10.62.216.37"], "pragma"=>["no-cache"]}>
--------------------------------------------------------
#
https://github.com/mmangino/mogli/blob/master/lib/mogli/client.rb
def raise_error_if_necessary(data)
raise HTTPException if data.respond_to?(:code) and data.code != 200
if data.kind_of?(Hash)
if data.keys.size == 1 and data["error"]
self.class.raise_error_by_type_and_message(data["error"]
["type"], data["error"]["message"])
end
end
end
So we modified the code a bit to get the response logged so we know
which one it is.
#
https://github.com/mmangino/mogli/blob/master/lib/mogli/client.rb
(modified)
def raise_error_if_necessary(data)
if data.respond_to?(:code) and data.code != 200
# DEBUG
@logger ||= Logger.new('./log/production.log')
@logger.error '------------- Mogli::Client::HTTPException
-------------'
@logger.error Time.now
@logger.error "data.code: #{ data.code }" if data.respond_to?
(:code)
@logger.error data.inspect
@logger.error
'--------------------------------------------------------'
raise HTTPException
end
if data.kind_of?(Hash)
if data.keys.size == 1 and data["error"]
self.class.raise_error_by_type_and_message(data["error"]
["type"], data["error"]["message"])
end
end
end
Don't know if it helps, but it's worth a try.
Ollie