Accessing Confluence APis via 3lo app cloud id and oauth token always return 401

Hi All,

I have set up a 3lo app. Provided app with necessary scopes to work with conflunce apis. When I fetch accessible-resources for an access token I obtained following authorization code oauth flow( as per documentation https://developer.atlassian.com/cloud/confluence/oauth-2-3lo-apps/#distributing-your-oauth-2-0--3lo--apps), I get

  {
        "id": "id-7e7e-4d7a-8d74-",
        "url": "mysite url",
        "name": "mysitename",
        "scopes": [
            "manage:confluence-configuration",
            "read:confluence-content.all",
            "read:confluence-content.permission",
            "read:confluence-content.summary",
            "read:confluence-groups",
            "read:confluence-props",
            "read:confluence-space.summary",
            "read:confluence-user",
            "readonly:content.attachment:confluence",
            "search:confluence",
            "write:confluence-content",
            "write:confluence-file",
            "write:confluence-groups",
            "write:confluence-props",
            "write:confluence-space"
        ],
        "avatarUrl": "avatar image url"
    }

but when I try to fetch my site resources using cloud id of my app, using the same token (as a bearer token) I always get

{
    "code": 401,
    "message": "Unauthorized"
}

Steps I have executed:

1.created a 3lo app in developer console.
2.granted app with required scopes.
3.obtained an access token by following authorization code flow, for my app’s authorization url
4. verified accessible resources for the token I have obtained. (using /oauth/token/accessible-resources api)
5. use the same token used in above step to fetch resources from my site,
/ex/confluence/{my-site-id}/wiki/api/v2/spaces/{my-space-id}

I have retrieved space ids for spaces in my site using basic authorization (using username, api token as basic auth headers), and all confluence apis work fine when I use basic authorization.

Can somebody please help me with resolving this issue of getting 401 when trying to used oauth access token to connect with confluence apis? Any thoughts?

Are you sure you are calling the API endpoints from the right url?
When using a 3lo integration you should use the following url to access the REST API https://api.atlassian.com/ex/confluence/{cloudid}/{api}

Yes, I am using this format.

Hi!

Have you been able to solve this?
I am facing the same issue with the Conffluence API v2 via 3lo, the API v1 is working perfectly but I am not being able to query the API v2, I am using the Bearer oAuth token (as with v1) and I have tried the following URLs, all with a 401 response:

api.atlassian.com/ex/confluence/{cloudid}/wiki/api/v2/spaces
api.atlassian.com/ex/confluence/{cloudid}/rest/api/v2/spaces
api.atlassian.com/ex/confluence/{cloudid}/wiki/api/2/spaces
api.atlassian.com/ex/confluence/{cloudid}/rest/api/2/spaces

The documentation for 3LO is not clear, it shows an example for Confluence API v1 which works, but there is no example for the API v2: https://developer.atlassian.com/cloud/confluence/oauth-2-3lo-apps/#3-2-construct-the-request-url

Please help, thanks!

Hi were you able to resolve this ?

also how did you get the cloud id?

also how did you get the cloud id?

You can find answer to frequently asked questions like that with Google.

Just Google “how to get Atlassian Client ID” and the very first result is the answer.

hi I looked a lot for this one but all i get is- account id or client id or application id or max to max jira cloud id i need for confluence

If you read the documentation for OAuth 2.0 apps, the information about creating and then finding a Client ID is described there also.

I’ve cut and pasted that part of the documentation here for you…

The query parameters for the authorization URL are described below:

  • client_id: (required) Set this to the Client ID for your app. Find this in Settings for your app in the developer console.

Hi thankyou for this.