lib/signet/oauth_2.rb in signet-0.2.4 vs lib/signet/oauth_2.rb in signet-0.3.0

- old
+ new

@@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. require 'base64' require 'signet' -require 'json' +require 'multi_json' module Signet #:nodoc: ## # An implementation of http://tools.ietf.org/html/draft-ietf-oauth-v2-10 # @@ -74,11 +74,11 @@ def self.parse_json_credentials(body) if !body.kind_of?(String) raise TypeError, "Expected String, got #{body.class}." end - return JSON.parse(body) + return MultiJson.decode(body) end ## # Generates a Basic Authorization header from a client identifier and a # client password. @@ -112,16 +112,16 @@ # @return [String] # The value for the HTTP Basic Authorization header. def self.generate_bearer_authorization_header( access_token, auth_params=nil) # TODO: escaping? - header = "OAuth #{access_token}" + header = "Bearer #{access_token}" if auth_params && !auth_params.empty? header += (", " + - auth_params.inject('') do |accu, (key, value)| - accu += "#{key}=\"#{value}\"" + (auth_params.inject([]) do |accu, (key, value)| + accu << "#{key}=\"#{value}\"" accu - end + end).join(", ") ) end return header end