mirror of
https://github.com/nirvana-7777/script.service.ultimate.git
synced 2026-09-18 23:22:38 +02:00
Add Magenta 2.0 (DE)
This commit is contained in:
@@ -404,8 +404,15 @@ class Magenta2Authenticator(BaseOAuth2Authenticator):
|
||||
|
||||
def update_sam3_client_id(self, client_id: str) -> None:
|
||||
"""Public method to update SAM3 client ID"""
|
||||
old_client_id = self._sam3_client_id
|
||||
self._sam3_client_id = client_id
|
||||
logger.debug(f"Updated SAM3 client ID: {client_id}")
|
||||
|
||||
# Also update the SAM3 client if it exists
|
||||
if self._sam3_client:
|
||||
self._sam3_client.update_sam3_client_id(client_id)
|
||||
logger.info(f"✓ Updated SAM3 client ID: {old_client_id[:8]}... -> {client_id[:8]}...")
|
||||
else:
|
||||
logger.debug(f"Updated SAM3 client ID (no client to update yet): {client_id}")
|
||||
|
||||
def update_client_model(self, client_model: str) -> None:
|
||||
"""Public method to update client model"""
|
||||
|
||||
@@ -670,4 +670,57 @@ class Sam3Client:
|
||||
f"auth={bool(self.authorization_endpoint)}, "
|
||||
f"oauth_token={bool(self.oauth_token_endpoint)}, "
|
||||
f"line_auth={bool(self.line_auth_endpoint)}, "
|
||||
f"backchannel={bool(self.backchannel_start_url)}")
|
||||
f"backchannel={bool(self.backchannel_start_url)}")
|
||||
|
||||
def update_sam3_client_id(self, new_client_id: str) -> None:
|
||||
"""Update SAM3 client ID and recreate remote login handler"""
|
||||
old_client_id = self.sam3_client_id
|
||||
self.sam3_client_id = new_client_id
|
||||
|
||||
# Invalidate the existing remote login handler so it gets recreated with new client ID
|
||||
if self._remote_login_handler:
|
||||
logger.debug(
|
||||
f"Invalidating remote login handler due to client ID change: {old_client_id} -> {new_client_id}")
|
||||
self._remote_login_handler = None
|
||||
|
||||
logger.info(f"✓ Updated SAM3 client ID to: {new_client_id}")
|
||||
|
||||
def _get_remote_login_handler(self) -> Optional['RemoteLoginHandler']:
|
||||
"""
|
||||
Get or create remote login handler
|
||||
"""
|
||||
# Return existing handler if available
|
||||
if self._remote_login_handler:
|
||||
return self._remote_login_handler
|
||||
|
||||
# Check if we have required endpoints
|
||||
has_backchannel = bool(self.backchannel_start_url)
|
||||
has_token_endpoint = bool(self._get_token_endpoint())
|
||||
has_qr_template = bool(self.qr_code_url_template)
|
||||
|
||||
if not all([has_backchannel, has_token_endpoint, has_qr_template]):
|
||||
# Detailed debug logging
|
||||
logger.debug("🚫 Remote login not available - missing endpoints:")
|
||||
logger.debug(f" • backchannel_start_url: {has_backchannel} -> {self.backchannel_start_url}")
|
||||
logger.debug(f" • token_endpoint: {has_token_endpoint} -> {self._get_token_endpoint()}")
|
||||
logger.debug(f" • qr_code_url_template: {has_qr_template} -> {self.qr_code_url_template}")
|
||||
return None
|
||||
|
||||
# LAZY IMPORT to avoid circular dependency
|
||||
try:
|
||||
from .remote_login_handler import RemoteLoginHandler
|
||||
except ImportError as e:
|
||||
logger.error(f"Failed to import RemoteLoginHandler: {e}")
|
||||
return None
|
||||
|
||||
# Create handler with CURRENT client ID
|
||||
self._remote_login_handler = RemoteLoginHandler(
|
||||
http_manager=self.http_manager,
|
||||
sam3_client_id=self.sam3_client_id, # Use current value
|
||||
backchannel_start_url=self.backchannel_start_url,
|
||||
token_endpoint=self._get_token_endpoint(),
|
||||
qr_code_url_template=self.qr_code_url_template
|
||||
)
|
||||
|
||||
logger.info(f"✓ Remote login handler initialized with client_id: {self.sam3_client_id[:8]}...")
|
||||
return self._remote_login_handler
|
||||
Reference in New Issue
Block a user