3
我試圖使用雙腿身份驗證來連接OAuth使用者。我有兩個問題:使用oauth-plugin在Rails中使用Jira 2L0在oauth中發生未經授權的錯誤
1)是否有可能使用OAuth與自定義REST插件(相對於內置API)
2)的測試內置的REST API,我「M嘗試以下內容,接收:
<Net::HTTPUnauthorized 401 Unauthorized readbody=true>
{"errorMessages":["You do not have the permission to see the specified issue","Login Required"],"errors":{}}
下面是測試方法:
jira_url = "http://localhost:2990/jira"
consumer_key = "hardcoded-consumer"
consumer_secret = OpenSSL::PKey::RSA.new(IO.read(File.dirname(__FILE__) + "/../rsakey.pem"))
@consumer ||= OAuth::Consumer.new(consumer_key, consumer_secret, {
:site => 'http://localhost:2990',
:context_path => '/jira',
:signature_method => 'RSA-SHA1',
:auth_type => :oauth,
:scheme => :header,
:oauth_callback => false,
:ssl_verify_mode => OpenSSL::SSL::VERIFY_PEER,
:use_ssl => true,
:http_method => :post,
:request_token_path => jira_url + '/plugins/servlet/oauth/request-token',
:access_token_path => jira_url + '/plugins/servlet/oauth/access-token',
:authorize_path => jira_url + '/plugins/servlet/oauth/authorize'
})
testurl = jira_url + "/rest/api/latest/issue/SPI-1"
puts "1 #################################### first method"
req = @consumer.create_signed_request(:get, testurl, nil)
res = Net::HTTP.start('localhost', '2990') { |http| http.request(req) }
puts res.inspect
puts res.body
puts "2 #################################### second method"
@acc_tok = OAuth::AccessToken.new @consumer
resp = @acc_tok.get(testurl)
puts @acc_tok.inspect
puts resp.inspect
puts resp.body
這兩種方法都輸出相同的錯誤。
誰能告訴我我做錯了什麼?
你有沒有想到這個問題,我面臨同樣的問題。 –
是rsakey.pem的指定位置是否正確? – Dave