Skip to content
Browse files

fix redirect uri format in Client#request

  • Loading branch information...
SophieDeBenedetto committed Jul 19, 2016
1 parent fb502c7 commit bf389481ec02f65aa2885a787dbbad342af084a3
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/oauth2/client.rb
@@ -89,8 +89,14 @@ def request(verb, url, opts = {}) # rubocop:disable CyclomaticComplexity, Method
connection.response :logger,$stdout) if ENV['OAUTH_DEBUG'] == 'true'

url = connection.build_url(url, opts[:params]).to_s

response = connection.run_request(verb, url, opts[:body], opts[:headers]) do |req|
body = nil

This comment has been minimized.

Copy link

aviflombaum Aug 2, 2016


I think this is slightly clearn for LOC 92-98

body = if opts[:body]      
  opts[:body][:redirect_uri] = opts[:body][:redirect_uri].split("?").first

I'm also wondering if you really need to re-write opts[:body][:redirect_uri] and can rather leave the original value alone and do something like:

body = opts[:body] ? URI.encode_www_form(opts[:body][:redirect_uri].split("?").first) : opts

I would also suggest naming what you're doing with opts[:body][:redirect_uri].split("?").first it's some sort of sanitation and a private method seems like a good home so that you get something like:

body = opts[:body] ? URI.encode_www_form(sanitize_querystring_on_body_rediect_uri) : opts

if opts[:body]
opts[:body][:redirect_uri] = opts[:body][:redirect_uri].split("?").first
body = URI.encode_www_form(opts[:body])
body = opts
response = connection.run_request(verb, url, body, opts[:headers]) do |req|
yield(req) if block_given?
response =, :parse => opts[:parse])

0 comments on commit bf38948

Please sign in to comment.
You can’t perform that action at this time.