langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
92.37k stars 14.77k forks source link

Support personal access token (PAT) in ConfluenceLoader #5191

Closed EricSpeidel closed 1 year ago

EricSpeidel commented 1 year ago

Issue you'd like to raise.

The Atlassian API (including Confluence) supports just passing a PAT (as token=) to authenticate as a user, unfortunately the LangChain abstraction doesn't.

Suggestion:

Add an optional "token" parameter to ConfluenceLoader and use it to authenticate within as an alternative to api_key/password/oauth.

Jflick58 commented 1 year ago

The confluence example in your documentation still uses the password kwarg:

confluence = Confluence(
    url='https://your-domain.atlassian.net',
    username=jira_username,
    password=jira_api_token,
    cloud=True)

Looking at the code for the Atlassian Python package, I do see that token is an implicit argument to the Confluence constructor inherited from the AtlassianRestAPI class.

@zywilliamli do you know anything about this? If we can resolve the conflict between the package documentation and the code, I'd be happy to add this token in. As it stands I tend to want to default to the documented behavior.

felipeff commented 1 year ago

@Jflick58 The code snippet you provided is specific for using tokens in the cloud version, per the documentation. For companies that use the on-prem Data Center/Server editions that doesn't work and we have to use only the "token" parameter. This is documented on the original provided link.

I implemented the token argument on a personal fork so I could use the ConfluenceLoader on my confluence server/on-prem environment and confirm that this approach works and that using the username/password does not work. For reference, this is a link to my fork: https://github.com/felipeff/langchain (I can update the documentation/tests and send a merge request and tag you for review if you want)

Jflick58 commented 1 year ago

@felipeff ah, good catch! 😀 An MR would be great.