Make google auth package dependency explicit to simplify code

Previously google auth library was explicitly installed only for the
cloud variant of Khoj to minimize packages installed for non
production use-cases.

But it was being implicitly installed as a dependency of an explicit
package in the default installation anyway.

Making the dependency on google auth package explicit simplifies
the conditional import of google auth in code while not incurring any
additional cost in terms of space or complexity.
This commit is contained in:
Debanjum
2025-03-23 08:31:41 +05:30
parent 5fff05add3
commit 510cbed61c
2 changed files with 3 additions and 6 deletions

View File

@@ -43,12 +43,9 @@ class MagicLinkForm(BaseModel):
if not state.anonymous_mode:
missing_requirements = []
from authlib.integrations.starlette_client import OAuth, OAuthError
from google.auth.transport import requests as google_requests
from google.oauth2 import id_token
try:
from google.auth.transport import requests as google_requests
from google.oauth2 import id_token
except ImportError:
missing_requirements += ["Install the Khoj production package with `pip install khoj[prod]`"]
if not os.environ.get("RESEND_API_KEY") and (
not os.environ.get("GOOGLE_CLIENT_ID") or not os.environ.get("GOOGLE_CLIENT_SECRET")
):