Nymbo commited on
Commit
1efe1aa
·
verified ·
1 Parent(s): 91b062e

Update ui_components.py

Browse files
Files changed (1) hide show
  1. ui_components.py +7 -9
ui_components.py CHANGED
@@ -106,15 +106,13 @@ class UIComponents:
106
  def _create_login_section(self):
107
  """Create HuggingFace OAuth login section"""
108
  with gr.Group(elem_classes="login-section"):
109
- # Build a redirect URL that matches this Space's host to satisfy HF OAuth rules
110
- # Prefer using SPACE_HOST provided by Hugging Face Spaces; fall back to default behavior
111
- space_host = os.getenv("SPACE_HOST")
112
- login_kwargs: Dict[str, Any] = {"value": "Sign in for Inference"}
113
- if space_host:
114
- # Use a callback path on the same host as recommended by HF docs
115
- login_kwargs["redirect_url"] = f"https://{space_host}/login/callback"
116
-
117
- self.login_button = gr.LoginButton(**login_kwargs)
118
 
119
  def _create_provider_model_selection(self):
120
  """Create provider and model selection dropdowns with defaults"""
 
106
  def _create_login_section(self):
107
  """Create HuggingFace OAuth login section"""
108
  with gr.Group(elem_classes="login-section"):
109
+ # Let Gradio determine the correct redirect URL when running on Hugging Face Spaces.
110
+ # Overriding redirect_url can easily cause a host/scheme mismatch (e.g., double https:// or wrong domain),
111
+ # which results in: "Error 400: Invalid redirect_uri, must start with https://<space>.hf.space".
112
+ #
113
+ # On Spaces, Gradio auto-configures OAuth to the Space subdomain, so we intentionally do NOT pass redirect_url.
114
+ # If running locally, OAuth via HF won't work; use HF_TOKEN instead.
115
+ self.login_button = gr.LoginButton(value="Sign in for Inference")
 
 
116
 
117
  def _create_provider_model_selection(self):
118
  """Create provider and model selection dropdowns with defaults"""