Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: ConfluenceReader base url #13783

Open
1 task done
ricardoxu6 opened this issue May 28, 2024 · 3 comments
Open
1 task done

[Question]: ConfluenceReader base url #13783

ricardoxu6 opened this issue May 28, 2024 · 3 comments
Labels
question Further information is requested

Comments

@ricardoxu6
Copy link

ricardoxu6 commented May 28, 2024

Question Validation

  • I have searched both the documentation and discord for an answer.

Question

token = {"access_token": "<access_token>", "token_type": "<token_type>"}
oauth2_dict = {"client_id": "<client_id>", "token": token}

base_url = "https://yoursite.atlassian.com/wiki"

To use Confluence Reader to read pages on Confluence, it needs us to specify a base URL and the URL should be in the typical format of Atlassian Cloud, which ends with /wiki. So, if my Confluence is hosted on a custom domain, for instance, https://confluence.xxx.com/, is there any other way for us to use Confluence Reader?

@ricardoxu6 ricardoxu6 added the question Further information is requested label May 28, 2024
Copy link

dosubot bot commented May 28, 2024

Hello @ricardoxu6! I'm here to help you with any bugs, questions, or contributions you may have. Let's tackle this ConfluenceReader base url issue together.

Yes, you can use ConfluenceReader with a base URL that is hosted on a custom domain. The base_url parameter in the ConfluenceReader class is designed to accept any valid Confluence instance URL, including those hosted on custom domains.

Here is the relevant part of the code that shows how the base_url is used:

class ConfluenceReader(BaseReader):
    """Confluence reader.

    Reads a set of confluence pages given a space key and optionally a list of page ids

    Args:
        oauth2 (dict): Atlassian OAuth 2.0, minimum fields are `client_id` and `token`, where `token` is a dict and must at least contain "access_token" and "token_type".
        base_url (str): 'base_url' for confluence cloud instance, this is suffixed with '/wiki', eg 'https://yoursite.atlassian.com/wiki'
        cloud (bool): connecting to Confluence Cloud or self-hosted instance
    """

    def __init__(
        self, base_url: str = None, oauth2: Optional[Dict] = None, cloud: bool = True
    ) -> None:
        if base_url is None:
            raise ValueError("Must provide `base_url`")

        self.base_url = base_url

        try:
            from atlassian import Confluence
        except ImportError:
            raise ImportError(
                "`atlassian` package not found, please run `pip install"
                " atlassian-python-api`"
            )
        self.confluence: Confluence = None
        if oauth2:
            self.confluence = Confluence(url=base_url, oauth2=oauth2, cloud=cloud)
        else:
            api_token = os.getenv(CONFLUENCE_API_TOKEN)
            if api_token is not None:
                self.confluence = Confluence(url=base_url, token=api_token, cloud=cloud)
            else:
                user_name = os.getenv(CONFLUENCE_USERNAME)
                if user_name is None:
                    raise ValueError(
                        "Must set environment variable `CONFLUENCE_USERNAME` if oauth,"
                        " oauth2, or `CONFLUENCE_API_TOKEN` are not provided."
                    )
                password = os.getenv(CONFLUENCE_PASSWORD)
                if password is None:
                    raise ValueError(
                        "Must set environment variable `CONFLUENCE_PASSWORD` if oauth,"
                        " oauth2, or `CONFLUENCE_API_TOKEN` are not provided."
                    )
                self.confluence = Confluence(
                    url=base_url, username=user_name, password=password, cloud=cloud
                )

As long as you provide a valid base_url for your custom domain, the ConfluenceReader should work correctly [1].

Details

About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

@ricardoxu6
Copy link
Author

What if for my custom domain, those confluence pages' URLs do not have a page_id included in the url, can I still use the Confluence Reader

Copy link

dosubot bot commented May 28, 2024

Yes, you can use the ConfluenceReader class to read Confluence pages on a custom domain even if the URLs do not include a page_id. The load_data method allows you to specify Confluence pages using one of four mutually exclusive methods: space_key, page_ids, label, or cql (Confluence Query Language). Therefore, you can use space_key, label, or cql to read pages without needing to specify page_ids [1].

Details

About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant