Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Confluence REST API: Is there anyway to authenticate by JSESSIONID or crowd.token_key?

Hi guys,
I am using SSO with Crowd and Confluence.
Now I need get Confluence's data from 3rd custom application. Is there any way to authenticate by JSESSIONID or crowd.token_key?
Thanks in advance.

2 answers

2 accepted

5 votes
Answer accepted

Hi @tai nguyen,

In short, yes you can authenticate with session cookies when requesting Confluence REST API. You might want to take a look at this link which provides very good examples.

In your use case, the workflow will be (a little bit) more complex. My understanding is actually that you have a user accessing to a third party web app with a browser and that you want to send HTTP requests from that web app to Confluence's REST API on behalf of the end-user. In such a case:

1. The user's browser sends the crowd.token_key cookie (I actually assume that your third party web app, Confluence and Crowd are on the same domain)

2. Your third party web app requests any URL of the Confluence server along with the crowd.token_key cookie that was provided by the end-user's browser.

Confluence will send the SSO token to Crowd so as to verify if it is a valid one. The problem here is that your third party web app's IP address is different from the end-user's IP address so Crowd won't validate the token (you will see warnings in Crowd's logs saying that the validation factors differ).

You have two workarounds for this:

  • Either your uncheck 'Session configuration > Require consistent client IP address' in Crowd's administration console
  • Or you add a X-Forwarded-For header (containing the end-user's IP address) into the HTTP request to your Confluence server. You will also need to add your third-party web app's IP address to the trusted proxy servers list in Crowd's administration console.

3. Confluence will return a JSESSIONID cookie and an atlassian.xsrf.token cookie. You can now send your HTTP request along with the three cookies (JSESSIONID, crowd.token_key and atlassian.xsrf.token), plus the X-Forwarded-For header, to the Confluence REST API URLs

Hi @Bruno Vincent,

Thank you so much for your solution, I have tried and it worked.

Can I ask you one more question? That is have any risk when uncheck [Require consistent client IP address]?

Hi @Bruno Vincent

Because the Uncheck Require consistent client IP address solution is unsafe, I went to try the add a X-Forwarded-For header above.

But when I sent request with add X-Forwarded-For and SSO token, It returned 403 error code. So how to get the JSESSIONID which return from Confluence?

JSESSIONID is easy to get in JIRA, but seem like Confluence still not supported.

Thank you

Hi @tai nguyen,

I would not say that unchecking the 'Require consistent client IP address' is unsafe, but it's obviously less safe than leaving it checked.

If it works with the option unchecked and does not work anymore when the option is checked though you added the X-Forwarded-For header, then it's all about validation factors. So you have to verify which IP address was used in the validation factors when the Crowd SSO token was initially created and which one you set in the X-Forwarded-For header. Please follow the instructions detailed in the 'Diagnostic steps' paragraph on this page:

Hi Bruno,

Thank you so much for the reply.

I will try to check it.

1 vote
Answer accepted

Hi @tai nguyen,

That is good news, I'm glad that helped!

Well, unchecking the 'Require consistent client IP address' option is obviously less secure as anyone having your Crowd SSO cookie could impersonate you. That being said, it should not be trivial to steal your Crowd SSO cookie. Make sure to always use HTTPS and tick the 'Secure SSO cookie' checkbox in Crowd's administration console as detailed here. Apart from non secure connections, XSS is usually the main type of attacks to steal cookies. So, you should also make sure that your third-party web app code sets the httpOnly flag to 'true' on the Crowd SSO cookie.

Yes, I got it.

Thank you so much for the greate advice.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events