How to Log In to Confluence in Java

Hi All!

I'm trying to fetch page data from Confluence, however I need to authenticate myself first. I've tried searching around the web for solutions to this problem, but the posts that I've found are several years old. Here's my code:

ConfluenceAuthenticator auth = new ConfluenceAuthenticator();
HttpServletRequest servletRequest = ServletActionContext.getRequest();
HttpServletResponse servletResponse = ServletActionContext.getResponse();
auth.login(servletRequest,servletResponse,"sup","dawg",false); 

I don't know if this is the right approach, but it's what I've found so far. However, it doesn't work! Ultimately, Java is throwing a "class not found" error for "DefaultAuthenticator", and I believe that's because "DefaultHTTPClient" has been deprecated. At least, that's what the error log leads me to belive.

Upon revisiting the site I pulled this information from, it occurs to me that the post was originally made in 2013, so this is probably out of date.

I've been searching around for an answer that I can sort of wrap my head around and such, but I don't have a lot of experience with this sort of thing in the least, so any and every bit of help is much appreciated.

Thanks!

1 answer

0 vote

Why don't you use the Confluence REST API?

That's the clear, modern and documented way to remotely access Confluence.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

1,891 views 25 10
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