Perform browser-based authentication and update API key. Args: force_reauth: Force re-authentication even if cached credentials exist Returns: True if authentication successful, False otherwise
(self, force_reauth: bool = False)
| 115 | self._setup_local_processors() |
| 116 | |
| 117 | def authenticate(self, force_reauth: bool = False) -> bool: |
| 118 | """ |
| 119 | Perform browser-based authentication and update API key. |
| 120 | |
| 121 | Args: |
| 122 | force_reauth: Force re-authentication even if cached credentials exist |
| 123 | |
| 124 | Returns: |
| 125 | True if authentication successful, False otherwise |
| 126 | """ |
| 127 | try: |
| 128 | from .services.auth_service import get_authenticated_token |
| 129 | |
| 130 | token = get_authenticated_token(force_reauth=force_reauth) |
| 131 | if token: |
| 132 | self.api_key = token |
| 133 | |
| 134 | # Update cloud processor if it exists |
| 135 | for processor in self.processors: |
| 136 | if hasattr(processor, 'api_key'): |
| 137 | processor.api_key = token |
| 138 | logger.info("Updated processor with new authentication token") |
| 139 | |
| 140 | return True |
| 141 | else: |
| 142 | return False |
| 143 | |
| 144 | except ImportError: |
| 145 | logger.error("Authentication service not available") |
| 146 | return False |
| 147 | except Exception as e: |
| 148 | logger.error(f"Authentication failed: {e}") |
| 149 | return False |
| 150 | |
| 151 | def _setup_local_processors(self): |
| 152 | """Setup local processors based on GPU preferences.""" |
nothing calls this directly
no test coverage detected