I am using a Service Account with admin permissons and an API-token (=not Oauth2).
When I try to get all pages from all spaces with a specific label:
However when I try to POST <siteBaseUrl>/wiki/api/v2/admin-key I get an error: "Unauthorized; scope does not match"
So, how can I get all pages from all spaces with a specific label?
The Service Account would need to have access to all spaces.
Other pont, I don't think a service account can use this API endpoint (no scopes are defined).
But I might be wrong, have you made the service account a Confluence Admin? Could you try the API call to get an admin key again?
@Marc -Devoteam- Thanks for the quick answer!
The Service Account was already defined as App Admin in our Confluence App. That did not help. I thought the way to go was to enable the Admin Key. Too bad.
--
So, as I understand we need to make sure this Service Account has access to all spaces.
So, next steps for us is to define an automation flow to grant access for this Service Account to all spaces where it did not yet had access.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Or Have a normal account, your own and try the same action.
Does that work, I think it would.
Otherwise do you have a default admin group on all confluence spaces, add the service account in there.
Yes or create an automation to achieve the permission update.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I recommend going over the docs again on how to use the admin key:
https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-admin-key/#api-admin-key-get
The community post
Organization or site admin users can make subsequent calls to any of our existing REST APIs using their admin keys by simply adding the following HTTP header to their requests:
HTTP Header Name:
Atl-Confluence-With-Admin-KeyHTTP Header Value:
true
---
First, POST the admin key to enable it using the right JSON body.
Then you need to call this first, and then use the admin key in the headers of the other script.
An example:
API_ENDPOINT = f"{BASE_URL}/wiki/api/v2/admin-key"
# === REQUEST ===
response = requests.post(
API_ENDPOINT,
headers=headers,
auth=AUTH,
json=payload # Use `json=` instead of `data=` with `json.dumps`
)
Here, the API endpoint is the admin key. Hope this helps!
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Aaron,
Thanks for your answer.
And what you describe is exactly what I do.
The body I use is: "durationInMinutes": 60
And just do be clear....
When I do NOTHING with the Admin Key and I use an API to get all spaces, it gives me only the spaces where the Service Account has access to. So, autharization is okay, endpoint is okay. Only the permissions are not suffient.
Btw. we have a confluence app using "Teamwork Collection Enterprise". Is that some modern version of Enterprise?
The documentation of the Admin-Key API says:
Scopes
Forge and OAuth2 apps cannot access this REST resource.
Connect apps cannot access this REST resource.
But I am using a Service Account with admin permissions.
So, I am still stuck.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you share a screenshot of the permissions you've set for the service account?
What authentication type youve selected?
If you selected API, what scopes ahve you selected?
What access does it have?
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you add an oath2 token to the service account, as the admin key option in API requires this..
An AT won't work for this.
Or grant the service account Site admin permissions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.