diff --git a/lib/jira/client.rb b/lib/jira/client.rb index 522e8d80..db98bada 100644 --- a/lib/jira/client.rb +++ b/lib/jira/client.rb @@ -8,38 +8,39 @@ module JIRA # The client must be initialized with an options hash containing # configuration options. The available options are: # - # :site => 'http://localhost:2990', - # :context_path => '/jira', - # :signature_method => 'RSA-SHA1', - # :request_token_path => "/plugins/servlet/oauth/request-token", - # :authorize_path => "/plugins/servlet/oauth/authorize", - # :access_token_path => "/plugins/servlet/oauth/access-token", - # :private_key => nil, - # :private_key_file => "rsakey.pem", - # :rest_base_path => "/rest/api/2", - # :consumer_key => nil, - # :consumer_secret => nil, - # :ssl_verify_mode => OpenSSL::SSL::VERIFY_PEER, - # :ssl_version => nil, - # :use_ssl => true, - # :username => nil, - # :password => nil, - # :auth_type => :oauth, - # :proxy_address => nil, - # :proxy_port => nil, - # :proxy_username => nil, - # :proxy_password => nil, - # :use_cookies => nil, - # :additional_cookies => nil, - # :default_headers => {}, - # :use_client_cert => false, - # :read_timeout => nil, - # :http_debug => false, - # :shared_secret => nil, - # :cert_path => nil, - # :key_path => nil, - # :ssl_client_cert => nil, - # :ssl_client_key => nil + # :site => 'http://localhost:2990', + # :context_path => '/jira', + # :signature_method => 'RSA-SHA1', + # :request_token_path => "/plugins/servlet/oauth/request-token", + # :authorize_path => "/plugins/servlet/oauth/authorize", + # :access_token_path => "/plugins/servlet/oauth/access-token", + # :append_explicit_oauth_token_parameter => false, + # :private_key => nil, + # :private_key_file => "rsakey.pem", + # :rest_base_path => "/rest/api/2", + # :consumer_key => nil, + # :consumer_secret => nil, + # :ssl_verify_mode => OpenSSL::SSL::VERIFY_PEER, + # :ssl_version => nil, + # :use_ssl => true, + # :username => nil, + # :password => nil, + # :auth_type => :oauth, + # :proxy_address => nil, + # :proxy_port => nil, + # :proxy_username => nil, + # :proxy_password => nil, + # :use_cookies => nil, + # :additional_cookies => nil, + # :default_headers => {}, + # :use_client_cert => false, + # :read_timeout => nil, + # :http_debug => false, + # :shared_secret => nil, + # :cert_path => nil, + # :key_path => nil, + # :ssl_client_cert => nil, + # :ssl_client_key => nil # # See the JIRA::Base class methods for all of the available methods on these accessor # objects. @@ -65,6 +66,7 @@ class Client :request_token_path, :authorize_path, :access_token_path, + :append_explicit_oauth_token_parameter, :private_key, :private_key_file, :rest_base_path, diff --git a/lib/jira/oauth_client.rb b/lib/jira/oauth_client.rb index fcfface8..e5296216 100644 --- a/lib/jira/oauth_client.rb +++ b/lib/jira/oauth_client.rb @@ -11,7 +11,8 @@ class OauthClient < RequestClient access_token_path: '/plugins/servlet/oauth/access-token', private_key_file: 'rsakey.pem', consumer_key: nil, - consumer_secret: nil + consumer_secret: nil, + append_explicit_oauth_token_parameter: true }.freeze # This exception is thrown when the client is used before the OAuth access token @@ -75,8 +76,9 @@ def access_token end def make_request(http_method, url, body = '', headers = {}) - # When using oauth_2legged we need to add an empty oauth_token parameter to every request. - if @options[:auth_type] == :oauth_2legged + # Apparently we don't need to add an empty oauth_token parameter to every request; feature flagged here + # with :append_explicit_oauth_token_parameter to allow backwards compatibility + if @options[:auth_type] == :oauth_2legged && @options[:append_explicit_oauth_token_parameter] oauth_params_str = 'oauth_token=' uri = URI.parse(url) uri.query = if uri.query.to_s == ''