lib/goauth2/client.rb in goauth2-0.0.7 vs lib/goauth2/client.rb in goauth2-0.0.9

- old
+ new

@@ -71,22 +71,25 @@ @access_token = OAuth2::AccessToken.new(client, @token, :refresh_token => @refresh_token, :expires_at => @expires_at, :expires_in => @expires_in) end return @access_token end - def _get_jsonc(url, params={}) + def _get_jsonc(url, params={}, headers = {}) params.merge!({'alt' => 'jsonc'}) - res = _get(url, params) + res = _get(url, params, headers) end - def _get_json(url, params={}) + def _get_json(url, params={}, headers = {}) params.merge!({'alt' => 'jsonc'}) - res = _get(url, params) + res = _get(url, params, headers) end - def _get(url, params={}) - res = access_token.get(url, :params => params) - Goauth2::HashResponse.new(JSON.parse(res.body)) rescue res + def _get(url, params={}, headers = {}) + oauth_response = access_token.get(url, :params => params, :headers => headers) + hash_response = Goauth2::HashResponse.new(JSON.parse(oauth_response.body)) + {:oauth_response => oauth_response, :hash_response => hash_response} + rescue + res end def _post(url, params={}, headers={}) oauth_response = access_token.post(url, params, headers) JSON.parse(oauth_response) rescue oauth_response