lib/omniauth/strategies/fellowshipone.rb
# Re-write token_request method to gain access to the response
# (accessible via token_request_response)
#
# Adapted from OAuth::Consumer::token_request
Re-write token_request method to gain access to the response
(accessible via token_request_response)


Re - write token_request method to gain access to the response ( accessible via token_request_response )
def token_request(http_method, path, token = nil, request_options = {}, *arguments)
            @tr_response = request(http_method, path, token, request_options, *arguments)
            case @tr_response.code.to_i
            when (200..299)
              if block_given?
                yield @tr_response.body
              else
                CGI.parse(@tr_response.body).inject({}) do |h,(k,v)|
                  h[k.strip.to_sym] = v.first
                  h[k.strip]        = v.first
                  h
                end
              end
            when (300..399)
              uri = URI.parse(@tr_response.header['location'])
              @tr_response.error! if uri.path == path 
              self.token_request(http_method, uri.path, token, request_options, arguments)
            when (400..499)
              raise OAuth::Unauthorized, @tr_response
            else
              @tr_response.error!
            end
          end
def token_request ( http_method , path , token = nil , request_options = { } , * arguments ) @tr_response = request ( http_method , path , token , request_options , * arguments ) case @tr_response . code . to_i when ( 200 .. 299 ) if block_given? yield @tr_response . body else CGI . parse ( @tr_response . body ) . inject ( { } ) do | h , ( k , v ) | h [ k . strip . to_sym ] = v . first h [ k . strip ] = v . first h end end when ( 300 .. 399 ) uri = URI . parse ( @tr_response . header [ 'location' ] ) @tr_response . error! if uri . path == path self . token_request ( http_method , uri . path , token , request_options , arguments ) when ( 400 .. 499 ) raise OAuth :: Unauthorized , @tr_response else @tr_response . error! end end
Re-write token_request method to gain access to the response
(accessible via token_request_response)
Re - write token_request method to gain access to the response ( accessible via token_request_response )
# symbolize keys # TODO this could be considered unexpected behavior; symbols or not? # TODO this also drops subsequent values from multi-valued keys # this is a redirect # careful of those infinite redirects
http_method
path
token
request_options
arguments