It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

JIRA Rest API authentication always returns 401 unauthorized

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

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

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
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you