Getting session cookie from jira cloud /rest/auth/1/session does not work

M K October 16, 2019

I am trying to get a session cookie from:

POST

https://xxx.atlassian.net/rest/auth/1/session

{"username":"aaaa","password":"bbbb"}

 

I am pretty sure that the provided credentials are correct - I can login with them in the web interface. However the call made with Postman always returns:

{ "errorMessages": [ "Login failed" ], "errors": {}}

There is no response header that would give any more information why it fails.

 

What could be the reason? I was thinking that maybe it is catpcha, but I cannot check that, as I always get redirected to https://id.atlassian.com  when I try to access the Jira login page directly.

 

 

2 answers

1 vote
DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 16, 2019

@M KCookie based authentication has been deprecated and removed for Jira cloud in favor of token based basic authentication.

You can learn more from this notification which is more then 6 months old - https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-basic-auth-and-cookie-based-auth/

M K October 17, 2019

Thank you for the information. I understand that token based authentication only applies to Jira cloud. Is there a way to implement authentication in javascript that would work for both Jira cloud and Jira server?

Cookie based authentication did work well for both server types.

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 17, 2019

@M KI made a small script in NodeJS for copying attachment from Server to Cloud (and vice versa), and I used BasicAuth for both. The only difference is in server/dc environment you have to use 'username' and 'password' combo whereas in cloud you have to use 'email' and 'api token' combo, when I made a UI for this, in form I mentioned this for users.

So I think BasicAuth is good enough for these kind of use cases.

M K October 18, 2019

Thank you. In the older server versions I am using a call to /session to get a session cookie. I guess I will have to change that to basic auth.

When calling jira server with username / password, do you encode the string to base64 like when calling jira Cloud?

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 18, 2019

Yes, BASE64 encoding is required for server version also.

You can refer this - https://developer.atlassian.com/server/jira/platform/basic-authentication/

M K October 18, 2019

I would like to ask you for a small favour. Since I do not have access to a Jira Server, would you be so kind to test if my script works with Jira Server too? It can be installed in Chrome / Opera / Firefox from: https://www.novibyte.com/

I think you might like it.

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 18, 2019

I can try it on Monday on test instance.

M K October 21, 2019

DPK,

 

If you try the iPlugin script, you can best use Chrome; the webstore now publishes the latest version 5.0. It can be installed here:  https://www.novibyte.com/

 

I could test it on Jira Cloud. It would be great to hear if it also works on Jira Server.

 

Best,

MPK

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 21, 2019

@M KTwo issues so far,

1. Window is too much transparent, and if you site is blue it become difficult to read text in plugin dialog.

Screenshot 2019-10-22 at 10.29.50 AM.png

2. When I entered site details, and pressed `LOGIN` button, nothing happen. Neither there was indicator of processing nor any action happen even after 2-3 minutes. I have triple checked credentials I was using. Also there was not network request, so it seems like some JS issue.

 

I hope this help.

M K October 22, 2019

That is strange indeed. The calls to Jira are made by the background page. You can open it by extensions > iPlugin > background page. It should show why the call fails. 

 

Also, if you could provide me with a test account on some Jira server accessible from outside, I could test it myself. If that is not possible, I understand.

 

PS If you try the same with Jira Cloud it should work fine with emai / API Token login.

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 22, 2019

Marek,

You can this site one company has hosted for demo of Requirement Management tool called RMsis, there product (make sure you don't use at large scale).

Credentials are,

Site - https://jira-rmsis.optimizory.com

Username - pm1

Password - project123

 

Hopefully this resolves your issue.

Stefan Gabura June 3, 2020

This helped me so much, many thanks!

0 votes
M K October 18, 2019

That would be great, I thank you in advance. May I ask your name? My name is Marek.

Suggest an answer

Log in or Sign up to answer