SmartBear / ready-jira-plugin

Provides ReadyAPI - Jira integration based on Jira rest API
4 stars 7 forks source link

Cannot connect to Jira Server v9.4.17 using a token #215

Open hilsonp opened 5 months ago

hilsonp commented 5 months ago

I can connect to the Jira API using a curl using the Authorization Bearer like this: curl -vH "Authorization: Bearer abcdefghabcdefghijklabcdefghijklabcdefghijkl" https://myjiraserver.com/jira/rest/api/2/project

The Bearer token was created like this: https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/

When I configure the Jira Plugin in ReadyAPI (pro), I'm forced to specify "email or username". I can then provide an API Token and the Jira server URL

I tried with both my username and my email address (seen in my Jira Profile), my valid API token and the server address. This fails.

Here is an abstract from the "HTTP Log" for a trial with my username (USER1), my API token and the server address https://myjiraserver.com/jira/

http-outgoing-11 >> "GET /jira/rest/api/2/project HTTP/1.1[\r][\n]"
http-outgoing-11 >> "Authorization: Basic xyzxyzxyzxyzxyzxyzxyzxy=[\r][\n]"
http-outgoing-11 >> "Accept: application/json[\r][\n]"
http-outgoing-11 >> "Via: 1.1 localhost (Apache-HttpClient/4.5.13 (cache))[\r][\n]"
http-outgoing-11 >> "Host: myjiraserver.com[\r][\n]"
http-outgoing-11 >> "Connection: Keep-Alive[\r][\n]"
http-outgoing-11 >> "User-Agent: Atlassian HttpClient 2.1.5 / Atlassian JIRA Rest Java Client-5.2.4 (0) / Default[\r][\n]"
http-outgoing-11 >> "[\r][\n]"
http-outgoing-11 << "HTTP/1.0 403 Forbidden[\r][\n]"

The error is: Unable to retrieve information from JIRA. Possible causes: - The JIRA Integration plugin settings are invalid. You might have specified email instead of username. - You do not have enough permissions in JIRA.

From what I can see, the problem is that the API Token is used to compute an Authorization Basic.

Can you allow us to keep the "email or username" field empty and in this case:

Thank you.

hilsonp commented 5 months ago

Here is my little contribution to solve this problem: https://github.com/SmartBear/ready-jira-plugin/pull/216

But honnestly, all credit goes to other clever people: https://community.atlassian.com/t5/Jira-Software-questions/How-do-I-use-a-personal-access-token-PAT-in-jira-rest-java/qaq-p/1859167