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

Allow ConfluenceLoader authorization via Personal Access Tokens #25096

Merged
merged 3 commits into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 39 additions & 8 deletions libs/community/langchain_community/document_loaders/confluence.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,22 +256,53 @@ def validate_init_args(
x is not None for x in ((api_key or username), session, oauth2, token)
)
if sum(non_null_creds) > 1:
all_names = ("(api_key, username)", "session", "oath2", "token")
all_names = ("(api_key, username)", "session", "oauth2", "token")
provided = tuple(n for x, n in zip(non_null_creds, all_names) if x)
errors.append(
f"Cannot provide a value for more than one of: {all_names}. Received "
f"values for: {provided}"
)
if oauth2 and set(oauth2.keys()) != {
"access_token",
"access_token_secret",
"consumer_key",
"key_cert",
}:

if (
oauth2
and set(oauth2.keys())
== {
"token",
"client_id",
}
and set(oauth2["token"].keys())
!= {
"access_token",
"token_type",
}
):
# OAuth2 token authentication
errors.append(
"You have either omitted require keys or added extra "
"keys to the oauth2 dictionary. key values should be "
"`['access_token', 'access_token_secret', 'consumer_key', 'key_cert']`"
"`['client_id', 'token': ['access_token', 'token_type']]`"
)

if (
oauth2
and set(oauth2.keys())
!= {
"access_token",
"access_token_secret",
"consumer_key",
"key_cert",
}
and set(oauth2.keys())
!= {
"token",
"client_id",
}
):
errors.append(
"You have either omitted required keys or added extra "
"keys to the oauth2 dictionary. key values should be "
"`['access_token', 'access_token_secret', 'consumer_key', 'key_cert']` "
"or `['client_id', 'token': ['access_token', 'token_type']]`"
)
return errors or None

Expand Down
Loading