Invalid content type value.
Created by: kaczor1984
Hello,
We're writing a code using your oauth2 library (1.4.7 at the moment). And while writing tests we wanted to replace the requests with a Faraday test replacement.
And it would all be nice except one reason: We write sth. like that in the rspec file:
subject.client.connection = Faraday.new(subject.client.site, subject.client.options[:connection_opts]) do |builder|
builder.adapter(:test) do |stub|
stub.post('https://github.com/login/oauth/access_token') do |env|
[200, { 'content-type': 'application/json', 'Accept': 'application/json' }, credentials.to_json]
end
end
end
And everything would be nice except one of the lines in your code is working a bit different: https://github.com/oauth-xx/oauth2/blob/master/lib/oauth2/response.rb#L93 In this line you check if the 'Content-Type' or the 'content-type' is equal to any of the values and our 'content-type' is somehow changed since that moment to 'Content-type' which is not caught. Could you change this method to catch also the Content-type ? Or should we use any extra condition to keep this content type the way we would like them to ?
I checked also the 'Content-Type' but it also is changed to 'Content-type' on the road to your gem.
If you would like to use it I prepared a fix for that issue (only a part of your code did not pass the rubocop validations): https://github.com/oauth-xx/oauth2/pull/577