Q:

jira-ruby plugin : Pass API Token instead of username and password

I am using jira-ruby Gem. 
require 'jira-ruby'

options = {
:username     => 'xxxxxxxx',
:password     => '********',
:site         => 'https://xxx.yyyy.com',
:context_path => '',
:auth_type    => :basic,
:use_ssl => true
}

client = JIRA::Client.new(options)
project = client. Project.find('P-NAME')

project.issues.each do |issue|
  puts "#{issue.id} - #{issue.summary}"
end

Here instead of passing the username and password, i want to pass API Token.  How can i do that????? 
Normal curl command which is working fine is : 
curl -X GET -H "Authorization: Basic <TOKEN>" "https://<URL HERE>/rest/api/2/issue/<ID>"

A:

There is no direct solution I found for this one.  Instead I've followed REST approach.  It will be simple.  Atlasssian has good api documentation. 
request_payload = {
  body: body, # Body as JSON
  query: params, # URL Parameters
  headers: {
    'Authorization' => "Basic #{auth_token}",
    'Content-Type' => 'application/json'
  }
}
response = HTTParty.send(:post, url, request_payload)
puts response

Please replace #{auth_token} with your API key.  Hope this will help somebody.