1
我正在使用oauth的rest-client,oauth標題正在生成,但hmac-sha1簽名無效。Ruby Oauth Gem HMAC-SHA1 401無效簽名
服務器不接受簽名編碼,返回401 oauth_problem signature_invalid。
oauth_signature="9aOk2oM2%2FczpqHBJ95MhcF%2Bp6XU%3D",
oauth_signature_method="HMAC-SHA1"
在郵遞員中運行「未編碼OAuth簽名」未選中工作正常。 當打開此選項時,郵遞員會提供相同的401無效簽名。
這是編碼的問題,有沒有類似的選項oauth寶石,我該如何設置它?
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'})
其餘客戶端2.0使用OAuth寶石0.5.1。,2.2.2紅寶石,不使用紅寶石上導軌