Confluence Cloud Rest API v2 oauth token not working

Hey there

I’ve been using Confluence Cloud Rest API v1 with Oauth authentication and it was working fine

However, trying to move to v2 of api and seems that it doesn’t work — all routes are returning 404 when I’m trying to use Bearer access token

Do you know what can be wrong?
Does v2 rest api support oauth2 auth?

Here’s an example of the request I’m trying to send

curl --location ‘https://quverr.atlassian.net/wiki/api/v2/spaces
–header ‘Authorization: Bearer oauth2-access-key’

Welcome to the Atlassian developer community @ArtjomMashanin,

I can’t explain why that style of request works for Confluence v1 but that’s URL pattern is wrong. The Atlasssian documentation on OAuth explains that request URLs should should be constructed like this:

https://api.atlassian.com/ex/confluence/{cloudid}/{api}

The documentation goes on to explain how to obtain the cloudid with a call to GET /oauth/token/accessible-resources. Be aware this endpoint can return more than 1 site and there is currently no way to just find the most recent authorization.

If you are using OAuth 2 only for your own site, there is a trick you can use to find the cloudid by checking:

https://<your-jira-instance>.atlassian.net/_edge/tenant_info
1 Like

Thanks @ibuchanan that was it!

Somehow by reading through the documentation I’ve assumed that the v2 uses company atlassian domain :man_facepalming: