REST authentication not setting cookies

I've been having a difficult time around authenticating a user remotely to my onDemand JIRA project. I'm creating a little dashboard and would like the users to login, view a certain query of issues, and when clicked taken to that specific issue's details. Currently "authenticating" with my below code results successful but, not setting cookies correctly (i assume) as users once clicked to details are asked to login again on the OnDemand project. Here is an abstract of my code.

Step 1: User enters user/pass on form and CURL is executed:

$url = "http://5thandpacific.atlassian.net/rest/auth/latest/session";

curl_setopt ($this->ch, CURLOPT_POST, true);
curl_setopt ($this->ch, CURLOPT_URL,$url);
curl_setopt ($this->ch, CURLOPT_TIMEOUT, 0);
curl_setopt ($this->ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt ($this->ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($this->ch, CURLOPT_USERPWD, "[USERNAME]:[PASSWORD]");
curl_setopt ($this->ch, CURLINFO_HEADER_OUT, true);
curl_setopt ($this->ch, CURLOPT_HEADER, true);

HERE IS THE OUTPUT:

However, when I click over to see details of the issue I'm asked to login again. The only cookie that is set is "Set-Cookie: studio.crowd.tokenkey". This is a OnDemand project and i've really tried at minimum a dozen examples (even down to command line CURL through PHP exec) but, no luck. I'm running the dashboard on a LAMP environment trying to authenicate a user and keep persistant cookie/session. Any help would be a dramatic time and stress saver for me.

2 answers

This widget could not be displayed.

The only cookie that is set is "Set-Cookie: studio.crowd.tokenkey"

You will need to also set the JSESSIONID cookie.

I assumed that but, don't know how. Is this something I can do with the above code? Am I creating a cookie through PHP? Do you have an example?

This widget could not be displayed.

url = new URL(urlString);
connection = (HttpsURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");

String cookie = connection.getHeaderField("Set-Cookie");

now use this cookie value on all the connections throughout you project

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

137 views 2 0
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