Ruby Oauth Gem HMAC-SHA1 401无效签名

Ruby Oauth Gem HMAC-SHA1 401无效签名,ruby,oauth,rest-client,Ruby,Oauth,Rest Client,我将rest客户机与oauth一起使用,生成oauth头,但是hmac-sha1签名无效 服务器不接受签名编码,返回401 oauth\u问题签名\u无效 oauth_signature="9aOk2oM2%2FczpqHBJ95MhcF%2Bp6XU%3D", oauth_signature_method="HMAC-SHA1" 运行在邮递员与“编码OAuth签名”联合国选定的作品很好。 启用此选项时,邮递员会给出相同的401无效签名 这是编码问题吗?OAuthGem有类似的选项吗?我如

我将rest客户机与oauth一起使用,生成oauth头,但是hmac-sha1签名无效

服务器不接受签名编码,返回401 oauth\u问题签名\u无效

oauth_signature="9aOk2oM2%2FczpqHBJ95MhcF%2Bp6XU%3D",  
oauth_signature_method="HMAC-SHA1"
运行在邮递员与“编码OAuth签名”联合国选定的作品很好。 启用此选项时,邮递员会给出相同的401无效签名

这是编码问题吗?OAuthGem有类似的选项吗?我如何设置它

require 'rubygems'

require 'oauth'
require 'rest-client'

# auth keys read in from file
base_uri = 'http://dockerized-magento.local'
base_path = 'api/rest'
base_url = base_uri + '/' + base_path + '/customers'   # the fix

 @consumer=OAuth::Consumer.new auth['consumer_key'],
                               auth['consumer_secret'],
                               {:site => base_url }      # the fix
 # this was the error
 #                              {:site=> base_uri + base_path}

# Create the access_token for all traffic
access_token = OAuth::AccessToken.new(@consumer, 
                                      auth['token'], auth['token_secret'])

RestClient.add_before_execution_proc do |req, params|
  access_token.sign! req
end

response = RestClient::Request.execute(method: :get, url: url, 
                                       timeout: 60, 
                                       headers: {'Cache-Control' => 'no-cache'})

rest客户机2.0和oauth gem 0.5.1.,ruby 2.2.2,未使用ruby on rails

问题在于我错误地设置了基本url。我看到了这个:而且

基本URL是请求指向的URL,减去任何查询字符串或哈希参数。这里使用正确的协议很重要,因此请确保URL的“https://”或“http://”部分与发送到API的实际请求相匹配。我相应地调整了我的基本url

改变

     @consumer=OAuth::Consumer.new auth['consumer_key'],
                           auth['consumer_secret'],
                           {:site=> base_url}
为了清楚起见,我正在更新上面的代码

     @consumer=OAuth::Consumer.new auth['consumer_key'],
                           auth['consumer_secret'],
                           {:site=> base_url}