JIRA Rest API authentication always returns 401 unauthorized

Laurent Jadoul March 17, 2018

Hello,

 

I have read many topics on how to connect but either the doc they referred to doesn't exists or Jira evolved in such way that the solution doesn't work anymore.

 

So maybe someone can help me on :

I'm trying to connect for one week to the Rest API of Jira. As I have a Google G-Suite account, I wasn't able to found how to create a "jira password" for mu user name so I created an API-Token.

I've generated a API-Token and followed the example given in the documentation here :

https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-basic-authentication/\\ 
So i've tried this :

curl -D- -X GET -H "Authorization: Basic XXXXXXX" -H "Content-Type: application/json" "https://oniryx.atlassian.net/rest/api/2/issue/createmeta"

where XXXXXXX rplace the base64 encoding of laurent.jadoul;[API-Token Value].

It always ends with 401.

Can you please advice ?

Thanks in advance,

Laurent

1 answer

1 accepted

1 vote
Answer accepted
Paulo F_
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 27, 2018

Hi Laurent,

Can you try the following format:

user@example.com:API-Token Value

(Please notice the @example.com and the colon is used instead of a semicolon)

 

Example for encoding (requires openssl on your machine):

Command:

echo 'user@email:API-Token Value' | openssl base64

Output:

dXNlckBlbWFpbDpBUEktVG9rZW4gVmFsdWUK  

 

Example request:

Command:

curl -D- -X GET -H "Authorization: Basic dXNlckBlbWFpbDpBUEktVG9rZW4gVmFsdWUK" -H "Content-Type: application/json" "https://<domain>.net/rest/api/2/issue/createmeta"

 

Hope this helps!

Paulo Ferreira

ALEJANDRO GUADARRAMA August 16, 2018

It doesn't work if you access to Jira using OAuth even if you have user name and password, and generate a TOKEN

I tried any possible combination but nothing

Just work when I use

curl -u 'user_name:password' .  works

curl -u 'email:token' .  works

curl -u 'user_name:token' .  not works

curl -H -H 'Authorization: Basic <user_name:password base64> . not works

curl -H -H 'Authorization: Basic <email:token base64> . not works

Suggest an answer

Log in or Sign up to answer