Hello, I’m trying to create an app that impersonates a user and can search confluence with the same permissions as that user. I followed the guides for impersonation with Oauth2, but the responses from the api don’t include items that the impersonated user should have permissions to see.
I post here in the hopes someone can point me in the right direction. Implementing Oauth2 is new to me and maybe I’m missing something obvious.
Context:
- My goal is to create a service in our company servers that searches confluence, and shows only the results that the user has permission to read. When using our company service, the user will be prompted to login to confluence, and the company app will use the token to ensure that the permissions are respected.
- However, after configuring all this, the app can only read pages and spaces that are marked as public
- I’m following these guides: OAuth 2.0 (3LO) apps / Confluence scopes for OAuth 2.0 (3LO) and Forge apps
Our progress so far:
-
We created an app (type:OAuth2 integration) in the developer console, using the account of an admin in confluence.
-
Get the client_ID and client_secret associated with this integration
-
Set the scopes to “read:content-details:confluence”, “read:content:confluence”, “search:confluence” by adding them to the AuthorizationURL
-
Set the callback to an URL in our company, including our internal ID in place of ${YOUR_USER_BOUND_VALUE} (let’s call it companyID)
-
Tried presenting this authorization URL to a user, and after they accepted, we receive the token and the companyId
-
POST to
https://auth.atlassian.com/oauth/tokenusing the token that arrived at the callbackURL + the client_id + client_secret of our app -
We receive a response with access_token, scope, expires_in
-
We check that the access_token works by calling:
https://api.atlassian.com/oauth/token/accessible-resourcesas the guide suggests. The URL of our confluence is correct and the scopes are those requested -
Tried the token (as Bearer token) to GET
https://api.atlassian.com/me→ the name and information of the user that accepted the link is correct. OK
The problem:
- Tried to use the access_token at
https://COMPANY.atlassian.net/wiki/api/v2/spaces, but the response contains only spaces visible by everyone, and none of the spaces that the user should be able to read. Ifhttps://api.atlassian.com/meknows the impersonated user info, why does this endpoint not know?
So the question:
When impersonating a user, where (as in, which URL/endpoint) am I supposed to use the access_token if i want to search pages?
-
I tried using it in the V1 api
https://COMPANY.atlassian.net/wiki/rest/api/searchcql=type=page&limit=25, but it responds with<status> <status-code>404</status-code> <message>null for uri: https://COMPANY.atlassian.net/wiki/rest/api/searchcql=type=page&limit=25</message> </status> -
I tries using it in the V2 api (
https://{your-domain}/wiki/api/v2/pages) but it only returns public pages, and not pages the user should be able to see -
Maybe there’s a third api I don’t know about?
