I think I'm doing something wrong. When calculating the canonical_string, I'm getting an empty content-type in the client but a text/plain content type in the server. The result is that the request cannot be autenticated:
Client canonical string: ,,/request-url,date
Server canonical string: text-plain,,/request-url,date
I've tested it with a simple GET request. I'm using Rails4 and ruby 2.0.0-p247
My model is using Activeresource to craft the request:
class Guide < ActiveResource::Base
self.site = ENV['API_BASE_URL']
with_api_auth ENV['APP_KEY'], ENV['APP_SECRET']
end
I could make it work with this (ugly and quick) patch to Headers.canonical_string:
# Returns the canonical string computed from the request's headers
def canonical_string
content_type = @request.content_type.blank? ? 'text/plain' : @request.content_type
[ content_type,
@request.content_md5,
@request.request_uri.gsub(/http:\/\/[^(,|\?|\/)]*/,''), # remove host
@request.timestamp
].join(",")
end
Is there a way to specify a default content type for the request?
Hi:
I think I'm doing something wrong. When calculating the canonical_string, I'm getting an empty content-type in the client but a text/plain content type in the server. The result is that the request cannot be autenticated:
Client canonical string: ,,/request-url,date Server canonical string: text-plain,,/request-url,date
I've tested it with a simple GET request. I'm using Rails4 and ruby 2.0.0-p247
My model is using Activeresource to craft the request:
class Guide < ActiveResource::Base self.site = ENV['API_BASE_URL'] with_api_auth ENV['APP_KEY'], ENV['APP_SECRET'] end
I could make it work with this (ugly and quick) patch to Headers.canonical_string:
Is there a way to specify a default content type for the request?
Thanks.
Note: I'm quite new to ruby and rails.