How to authorize users of confluence using other web application

I would like to authorize the profile of a Confluence user through the web-based application; everything should be managed through programming(i.e. access token should create through code and will take it to process further).

I am here to request data from Confluence application using my other webapplication.
While performing operation in my application, will try to authenticate/authorize in confluence application using recommended mechanism.

If you want to access Confluence APIs from an external application, you would need to implement the authorization code grant as explained in this page https://developer.atlassian.com/cloud/confluence/oauth-2-3lo-apps/
But you need to handle the flow yourself and also take care of token renewals whenever they expire.

Thank you for response.

As per shared link it is for cloud, I am looking for datacenter (It can be same).
Just one more question, do I need to configure application to get clientid?
Based on clientid I can generate the authcode/access token accordingly, Is this correct understanding here. Thank you !

Documentation for server/datacenter: https://developer.atlassian.com/server/confluence/confluence-oauth2-provider-api/

Here is a very basic example of the steps after you created your application:


### 1. Open the Dialog to get an "authorization code"
GET {{baseUrl}}/rest/oauth2/1.0/authorize
    ?client_id={{clientId}}
    &response_type=code
    &redirect_uri={{redirectUrl}}
    &scope=WRITE
Authorization: Bearer {{personalAccessToken}}

### Use the "authorization code" to get an "access token"
POST {{baseUrl}}/rest/oauth2/latest/token
Content-Type: application/x-www-form-urlencoded
Accept: application/json

client_id = {{clientId}} &
client_secret = {{clientSecret}} &
code = {{authorizationCode}} &
grant_type = authorization_code &
redirect_uri = {{redirectUrl}}

### Use the "access token" to do your work

GET {{baseUrl}}/rest/api/content/
Authorization: Bearer {{accessToken}}
Accept: application/json

There is also an API for renewal, unfortunately the token only has a very short lifetime …

2 Likes

Thank you, I will check this.