{"record":{"id":"bb424a8ba9f6e555","repo":"odysseus-dev/odysseus","slug":"google-oauth-token-unavailable-reconnect-the-acc-bb424a","errorCode":null,"errorMessage":"Google OAuth token unavailable — reconnect the account","messagePattern":"Google OAuth token unavailable — reconnect the account","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"routes/email_routes.py","lineNumber":5867,"sourceCode":"        imap_pass = body.get(\"imap_password\") or \"\"\n        imap_starttls = bool(body.get(\"imap_starttls\"))\n        oauth_provider = body.get(\"oauth_provider\") or \"\"\n\n        google_token = None\n        google_token_loaded = False\n        google_ssl_context = (\n            ssl.create_default_context()\n            if oauth_provider == \"google\"\n            else None\n        )\n\n        def _google_token():\n            nonlocal google_token, google_token_loaded\n            if not google_token_loaded:\n                google_token = _get_valid_google_token(body.get(\"account_id\"), body)\n                google_token_loaded = True\n            if not google_token:\n                raise RuntimeError(\"Google OAuth token unavailable — reconnect the account\")\n            return google_token\n\n        if imap_port_err:\n            imap_result = {\"ok\": False, \"error\": imap_port_err}\n        elif not (imap_host and imap_user and (imap_pass or oauth_provider == \"google\")):\n            imap_result = {\"ok\": False, \"error\": \"Need IMAP host, username, and password\"}\n        elif oauth_provider == \"google\" and _normalized_mail_host(imap_host) != _GOOGLE_OAUTH_IMAP_HOST:\n            imap_result = {\"ok\": False, \"error\": \"Google OAuth IMAP requires imap.gmail.com\"}\n        elif oauth_provider == \"google\" and not _google_oauth_imap_transport_allowed(imap_port, imap_starttls):\n            imap_result = {\"ok\": False, \"error\": \"Google OAuth IMAP requires TLS on port 993 or STARTTLS on port 143\"}\n        else:\n            # Connection mode resolution:\n            #   STARTTLS on  → plain IMAP4 + .starttls() (upgrade)\n            #   STARTTLS off + port 993 → IMAP4_SSL (implicit SSL, \"IMAPS\")\n            #   STARTTLS off + any other port → plain IMAP4 (no encryption)\n            # Without the last branch, local servers exposed on a non-993\n            # port (Dovecot on 31143, etc.) would always fail the SSL\n            # handshake because they're not actually wrapped in TLS.","sourceCodeStart":5849,"sourceCodeEnd":5885,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/email_routes.py#L5849-L5885","documentation":"Error \"Google OAuth token unavailable — reconnect the account\" thrown in odysseus-dev/odysseus.","triggerScenarios":"Triggered when the corresponding server-side validation or runtime check at the recorded location rejects the request or operation and returns this error message to the caller.","commonSituations":"See trigger scenarios.","solutions":["Reconnect the Google account in Settings → Integrations to refresh the OAuth token.","Check that Google OAuth credentials are still valid and scopes include mail access."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}