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

Update ui_components.py

Browse files
Files changed (1) hide show
  1. ui_components.py +10 -5
ui_components.py CHANGED
@@ -106,10 +106,15 @@ class UIComponents:
106
  def _create_login_section(self):
107
  """Create HuggingFace OAuth login section"""
108
  with gr.Group(elem_classes="login-section"):
109
- self.login_button = gr.LoginButton(
110
- value="Sign in for Inference",
111
- redirect_url="https://gradio-chat-gradio-app-hfips.hf.space/"
112
- )
 
 
 
 
 
113
 
114
  def _create_provider_model_selection(self):
115
  """Create provider and model selection dropdowns with defaults"""
@@ -475,4 +480,4 @@ class UIComponents:
475
  self.remove_all_btn.click(
476
  handle_remove_all,
477
  outputs=[self.server_checkboxes, self.add_server_output]
478
- )
 
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"""
 
480
  self.remove_all_btn.click(
481
  handle_remove_all,
482
  outputs=[self.server_checkboxes, self.add_server_output]
483
+ )