JIRA API Authentication - Cookie - No JSESSIONID but cloud.session.token

Leo_M July 11, 2017

I got this as response on trying to authenticate using rest/auth/1/session 

{"session":{"name":"cloud.session.token","value":"eyJraWQiOiJzZXNzaW9uLXN

Can i use this as JSESSIONID  ?

Another case is 

I am able to connect using Basic authentication after that am stuck. After login if there is a redirect ,   do i have to authenticate again on the new page ? So if i have multiple pages do i have to authenticate each time if i am using Basic Auth ?

 

2 answers

1 vote
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 13, 2017

Hi Leo,

The documentation needs to be updated as mentioned in:

In  order to make it working you just store all the cookie information in a file and use that to authenticate. E.g.:


1) Store the cookie in a cookie jar: 

curl -c cookie.txt -H "Content-Type: application/json" -d '{"username":"XXXXXXXXX", "password":"XXXXXXXXX" }' -X POST https://INSTANCE/rest/auth/1/session

OR

curl --cookie-jar cookie.txt -H "Content-Type: application/json" -d '{"username":"XXXXXXXXX", "password":"XXXXXXXXX" }' -X POST https://INSTANCE/rest/auth/1/session 

 

2) You can then use that to authenticate the successive REST calls:

curl -b cookie.txt --header "X-Atlassian-Token: no-check" -H "Content-Type: application/json" -X GET https://INSTANCE/rest/........

OR

curl --cookie cookie.txt --header "X-Atlassian-Token: no-check" -H "Content-Type: application/json" -X GET https://INSTANCE/rest/........ 

 

Cheers,
Dario

Leo_M July 13, 2017

Thanks  Dario .I will try that .

0 votes
Leo_M July 14, 2017

I got JSESSIONID on using it on our jira server and works fine . This one i will try on my test jira cloud!

 

@Dario B  one quick question  - i will not be able to use basic auth if log in and consequesnt request happening on different pages . Is my understanding correct ?  As there is no session in basic auth !

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 14, 2017

With basic auth you authenticate each request. So each request has its own session and this can impact your JIRA performances.

If you need to send multiple requests it is much better to use cookie authentication in order to avoid DoS-sing your JIRA instance :) 

Suggest an answer

Log in or Sign up to answer