JIRA Rest API authentication always returns 401 unauthorized

I have been trying for hours the following simple CURL command described in the documentation without any success. It always returns me a 401 unauthorized.

curl -D- -u "email:password" -X GET -H "Content-Type: application/json" https://textmaster.jira.com/rest/api/2/issue/TM-3450

I have checked that my confluence config has the "allow remote api calls" set to true. What should I do to make this work?

 

Note: I'm able to access the rest API from the browser directly, while logged in with my user account.

Note: It's a linked google account with a password set.

2 answers

1 accepted

Hi Pierre-Louis,

Silly question but your email is your username? if not then your command should be replaced with JIRA username. Also since your connection is https but -k at the end of the URL  and try again

curl -D- -u "username:password" -X GET -H "Content-Type: application/json" https://textmaster.jira.com/rest/api/2/issue/TM-3450 -k 

Also if that is not the case then you can try other authentication technique like Oauth.

Taha

I just wanted to add a comment because I skipped by this answer and then kept looking for a while before realizing this was the correct answer. Even though I login to confluence with `nate@mydomain.com`, that is not the username to user when authenticating against the api. Against the api, I have to use `nate` as the username.

This can't be stated enough. The API docs aren't clear and make it sound like the website authentication is exactly the same as the rest API authentication. The website works with both username and email as the "username" while the rest API only works with username. You can see your "username" by viewing your profile in JIRA.

Jesus... I spent hours trying to figure out why, are we supposed to be mind readers? You have to emphasize this fact in your documentation, since it's almost ubiquitous that both email and username can be used to authenticate.

Thank goodness; yes this solved it.

To complicate matters, the REST API was accepting with the email address as the login ID for the first minute or so after the first login with a new account, so it was working for a while ... and then not.

@ Jonathan Sullivan

My username is also my email address but Jira won't allow me to change the username to a new username.  So what can I do to make my authentication API work?

  Let say my email address is "nguyen7744@yahoo.com", can I send my authentication as: 

curl -D- -u "nguyen7744:password1234" -X GET -H "Content-Type: application/json" https://textmaster.jira.com/rest/api/2/issue/TM-3450

 

If that won't work then how can I change my current username (nguyen7744@yahoo.com) to a new username? Or I need to contact JIra's support?

Thanks

John Nguyen



Note that if you are logging in via a sync Google account, it is NOT the google password you are supposed to use. Also it is not the email.

Instead you should go to your user profile and look up your username and set a password.

https://confluence.atlassian.com/cloud/manage-your-profile-and-password-744721602.html

For site admin functions, RSS feeds, REST API access, or WebDAV uploads you'll need to have an Atlassian Cloud password (separate to your Google Apps password. If you haven't set an Atlassian Cloud password, go to the login page and choose Unable to access your account? in the Atlassian Cloud login section.

Of course it makes no sense that this information is not available on the REST API documentation page, since it is quite crucial to get it working.

Is there a way to do this in the new JIRA experience? I can't seem to find any information and the link you provided is now dead.

Having the same issue.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,338 views 14 20
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot