INNER CODE UNIT · Python
authenticate_agent
wkaisertexas/tiktok-uploader · src/tiktok_uploader/auth.py:73
def authenticate_agent(self, page: Page) -> Page:
"""
Authenticates the agent using the browser backend
"""
if not self.cookies:
self.cookies = self._resolve_cookies()
if not self.cookies and self.username and self.password:
self.cookies = login(page, username=self.username, password=self.password)
if not self.cookies:
raise InsufficientAuth(
"No valid authentication source found. Provide a valid cookies file, cookies list/string, sessionid, or username/password."
)
logger.debug(green("Authenticating browser with cookies"))
# Fix cookie keys for Playwright