sumoheavy / jira-ruby

A Ruby gem for the JIRA REST API
MIT License
655 stars 412 forks source link

Unauthorized (JIRA::HTTPError) during Jira connect via Access Token #404

Open kszorin opened 1 year ago

kszorin commented 1 year ago

Environment

Jira standalone 8.20.10 Authorization to Jira via User Token jira-ruby version: 2.2.0, 2.3.0 Bundler 2.4.12

Steps

options = {
    :site => ENV['JIRA_URL'],
    :context_path => '',
    :auth_type => :jwt,
    :default_headers => { 'Authorization' =>  "Bearer #{ENV['JIRA_ACCESS_TOKEN']}" }
  }
  client =  JIRA::Client.new(options)

   ...
  jql = "PROJECT = '#{project_name}' AND fixVersion = '#{jira_version}'"
  issues = client.Issue.jql(jql)   # <----------------------------------------------------- EXCEPTION!

Expect

Successful connection and JQL Response

Actual

bundler: failed to load command: fastlane (/builds/...-App/...-app-android/vendor/ruby/3.0.0/bin/fastlane)
/builds/...-App/...-app-android/vendor/ruby/3.0.0/gems/jira-ruby-2.3.0/lib/jira/request_client.rb:13:in `request': Unauthorized (JIRA::HTTPError)
    from /builds/...-App/...-app-android/vendor/ruby/3.0.0/gems/jira-ruby-2.3.0/lib/jira/client.rb:306:in `request'
    from /builds/...-App/...-app-android/vendor/ruby/3.0.0/gems/jira-ruby-2.3.0/lib/jira/client.rb:279:in `get'
    from /builds/...-App/...-app-android/vendor/ruby/3.0.0/gems/jira-ruby-2.3.0/lib/jira/resource/issue.rb:80:in `jql'
    from /builds/...-App/...-app-android/vendor/ruby/3.0.0/gems/jira-ruby-2.3.0/lib/jira/base_factory.rb:31:in `block (2 levels) in delegate_to_target_class'

What have I already checked

Token is valid (checked by curl) JQL is valid (checked by curl) Connection between GitLab and Jira (checked by curl)


Has anyone encountered this problem?

paderich commented 1 week ago

I have the same issue currently. It worked a week ago, now I get this issue, nothing in my setup changed.