Is there any Confluence REST API which authenticates a confluence
Asked by Aniket:

Working closely on Jira \& Confluence REST API's   
Jira API to authenticate user : <https://tickets.ingramcontent.com/rest/auth/1/session>

body

{  
"username": "someUserName",  
"password": "somePassword"  
}

<br />

So I've found the respective REST API for Jira for authenticating a jira_user...

But im unable to find a suitable REST API CONFLUENCE which authenticates a conf_user...\& need such that satisfies the same goal such as Jira REST API

Is there such Confluence REST API which authenticates a conf_user?

<br />

If Not....how do I find out a work-around to authenticate a conf_user ?

Thanks in advance.


Answers:
author: Shannon S
body: Hi Aniket

You'll need to authenticate prior to the call; you can see examples in this article:

[Confluence REST API Examples](https://developer.atlassian.com/confdev/confluence-server-rest-api/confluence-rest-api-examples)

See the text before the call:

```
curl -u admin:admin
```

Let us know if you have any questions.

Kind Regards,  
Shannon

comments: author: Aniket
body: apologies for late reply...kept this issue on stand by n moved on due to other priorities.

<br />

surely will work on your solution \& post my response once i go back n get that done. haven't got a chance to do so lately.

thanks for your reply [@Shannon S](/t5/user/viewprofilepage/user-id/510046)


author: Shannon S
body: Thanks, Aniket for the update!

Let us know if you have any trouble or questions.

Kind Regards,  
Shannon


author: Aniket
body: Hi Shannon.

My motive just was to validate the confluence user...which I am able to do very easily in the case of Jira...since jira has its own authenticateUser ReST API : [Jira Login](https://docs.atlassian.com/jira/REST/server/#auth/1/session-login "Jira's Login ReST API")

But there isn't any such dedicated ReST API for confluence login,  
or to authenticate confluence user at the moment.

**what u mentioned above worked for me. :)**

curl -u admin:admin

example :

curl -u user123@gmail.com:password123 -X GET -H "Content-Type: application/json" https://yourDomainName/rest/api/user?username=user123@gmail.com

writing down my small detailed findings for others who come across this same scenario.

<br />

The above curl command when executed internally first validates the credentials mentioned, which in turn if are valid then invokes the confluence url mentioned in the later part of the curl command.

therefore, we get a

**"200 OK"** response on success \& valid credentials.

**"401 unauthorized"** response is for INVALID credentials, i.e invalid userName or password provided.

**"403 forbidden"** i.e the API invoked was prompted for a CAPTCHA CHALLENGE. therefore the api invocation \& curl command execution failed and the response is 403...here the credentials are valid but due to **captcha challenge** it gave a 403 error. this might be handled of admin level for those user to disable the captcha.

the Confluence ReST API used is simple : [get user](https://docs.atlassian.com/confluence/REST/latest-server/#user-getUser "Get User")

++<https://docs.atlassian.com/confluence/REST/latest-server/#user-getUser>++

Initially I was really struggling...thought why couldn't confluence just expose a API for login/authenticateUser ... simply would have helped people n saved time. Anyways this does my intended work.

I actually saw that page \& overlooked it...at that time was just hunting for some dedicated API for this purpose. anyways..

Thanks for the Pointer.