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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

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

Challenges
Coins

Gift kudos to your peers

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

Recognition
Ribbon

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!

Leaderboard

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
4,555,139
Community Members
 
Community Events
184
Community Groups

How to authenticate to confluence server via curl

I want to authenticate to our confluence server via curl.

I use 

curl https://<MY HOST>/rest/pat/latest/tokens -H "Authorization: Bearer <MY PAT>"-H "Content-Type: application/json"

which results in

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>401</status-code><message>Client must be authenticated to access this resource.</message></status> 

 I also tried

curl https://<MY HOST>/rest/pat/latest/tokens -H "Authorization: Basic username:password"-H "Content-Type: application/json"

All results in the above response. When I call the /rest/pat/latest/tokens via browser after successful login I receive the correct tokens.

Are there any additional configuration settings in confluence to make the curl requests work?

Thanks in advance! 

1 answer

1 vote
Andrii Maliuta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 12, 2023 • edited

Hello @twentyonetwice .

Can you try to set the url as the last parameter?

 

curl -H "Authorization: Basic ${BASE64_TOKEN}" -H "Content-Type: application/json" https://<MY HOST>/rest/pat/latest/tokens 

BASE64_TOKEN is a "user:password" string encoded to base64 format.

e.g. with user admin and admin 

echo admin:admin | base64 -> dXNlcjp1c2VyCg==

curl -H "Authorization: Basic dXNlcjp1c2VyCg==" -H "Content-Type: application/json" https://<MY HOST>/rest/pat/latest/tokens



Hi Andrii, 

I already tried it the way you described. Url at last, basic authorization with base64-encoded username/password string. All tries resulted in the same response.

The docs are explaining both ways, but none of them is working.

Andrii Maliuta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 13, 2023

@twentyonetwice ,

Just to clarify: if you use already created PAT then you should use the Bearer type:

"Authorization: Bearer $Atlas_Token"

Basic auth is used with user and password.

Also, you can try other common REST API endpoint like

https://<MY HOST>/rest/api/content/

to check access to content.

https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html  

Hi @Andrii Maliuta

I've tried it both ways, the Bearer Authentication and the Basic Authentication. 

I've also tried it with rest/api/content, /rest/api/space and /rest/api/space/<SPACE_KEY>

None of those tries worked for me.

Andrii Maliuta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2023

@twentyonetwice ,

I suppose this is some inconsistency of using the correct user with the correct permissions and corresponding token, as it works well in such cases with correct config. Could you please make sure the user has correct Global permissions and instance level permissions?

Just to make sure the access is OK, you can try to use other tool like Postman, HttPie, etc. to see if it works well.

@Andrii Maliuta Finally we solve this problem. All my requests were correct, but there was a http-proxy before our confluence installation. 

Thanks for your efforts!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events