Open astorm opened 1 month ago
Just some additional datapoint -- as much for the Google searches as anything.
A colleague (hat tip @rowasc) pointed out that the oAuth2 request
method has two undocumented params -- full_response
and raw_response
that allow us to make requests without the automatic attempt as a json_decode
, and are suitable workarounds.
https://github.com/beaulebens/keyring/blob/trunk/includes/services/core/oauth2.php#L208
That said -- it still seems like the Google service classes could/should be aware of the multipart Content-Type
and do something smarter than return an empty error.
I ran into something that's either a bug or a missing feature (depending on your point of view). Would it be possible to add support for Google's batch requests (https://developers.google.com/gmail/api/guides/batch) to the built-in google classes (
Keyring_Service_GoogleMail
, etc.)The problem I ran into was, I was trying to use Google's batch mode with code that looked something like this (pseudo code)
The issue I ran into is the
request
method would return anull
value, but there wouldn't be an error otherwise. It seemed as though the HTTP request was succeeding. After digging into the issue a bit, I believe the culprit is this bit of code in the base OAuth class.The base OAuth2 class appears to assume the response will be a JSON formatted string. However, in the base of Google's batch API, the response is a multipart message. The
json_decode
function fails to parse this, returningNULL
.I realize there's workarounds -- implement my own service class that extends
Keyring_Service_GoogleMail
and include a multipart awareparse_response
method, or add a filter/listener for thehttp_response
filter and parse the response myself -- however it feels like this is something these classes should be able to handle themselves, or at minimum come back with an error that indicated the response could not be parsed.