diff --git a/backend/danswer/connectors/egnyte/connector.py b/backend/danswer/connectors/egnyte/connector.py index 73285644c16b..35e7c80e9d60 100644 --- a/backend/danswer/connectors/egnyte/connector.py +++ b/backend/danswer/connectors/egnyte/connector.py @@ -201,7 +201,7 @@ class EgnyteConnector(LoadConnector, PollConnector, OAuthConnector): ) @classmethod - def oauth_code_to_token(cls, code: str) -> dict[str, Any]: + def oauth_code_to_token(cls, base_domain: str, code: str) -> dict[str, Any]: if not EGNYTE_CLIENT_ID: raise ValueError("EGNYTE_CLIENT_ID environment variable must be set") if not EGNYTE_CLIENT_SECRET: @@ -211,12 +211,13 @@ class EgnyteConnector(LoadConnector, PollConnector, OAuthConnector): # Exchange code for token url = f"https://{EGNYTE_BASE_DOMAIN}.egnyte.com/puboauth/token" + redirect_uri = f"{EGNYTE_LOCALHOST_OVERRIDE or base_domain}/connector/oauth/callback/egnyte" data = { "client_id": EGNYTE_CLIENT_ID, "client_secret": EGNYTE_CLIENT_SECRET, "code": code, "grant_type": "authorization_code", - "redirect_uri": f"{EGNYTE_LOCALHOST_OVERRIDE or ''}/connector/oauth/callback/egnyte", + "redirect_uri": redirect_uri, "scope": "Egnyte.filesystem", } headers = {"Content-Type": "application/x-www-form-urlencoded"} diff --git a/backend/danswer/connectors/interfaces.py b/backend/danswer/connectors/interfaces.py index 3ab447a7a883..09884deb12d6 100644 --- a/backend/danswer/connectors/interfaces.py +++ b/backend/danswer/connectors/interfaces.py @@ -78,7 +78,7 @@ class OAuthConnector(BaseConnector): @classmethod @abc.abstractmethod - def oauth_code_to_token(cls, code: str) -> dict[str, Any]: + def oauth_code_to_token(cls, base_domain: str, code: str) -> dict[str, Any]: raise NotImplementedError diff --git a/backend/danswer/server/documents/standard_oauth.py b/backend/danswer/server/documents/standard_oauth.py index ddc85761914f..27b7964d6d3e 100644 --- a/backend/danswer/server/documents/standard_oauth.py +++ b/backend/danswer/server/documents/standard_oauth.py @@ -117,7 +117,8 @@ def oauth_callback( raise HTTPException(status_code=400, detail="Invalid OAuth state") original_url = original_url_bytes.decode("utf-8") - token_info = connector_cls.oauth_code_to_token(code) + base_url = WEB_DOMAIN + token_info = connector_cls.oauth_code_to_token(base_url, code) # Create a new credential with the token info credential_data = CredentialBase(