{"record":{"id":"ea1ba13371ec85fa","repo":"zeroclaw-labs/zeroclaw","slug":"ms365-device-code-polling-failed","errorCode":null,"errorMessage":"ms365: device code polling failed","messagePattern":"ms365: device code polling failed","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-tools/src/microsoft365/auth.rs","lineNumber":285,"sourceCode":"                    expires_at: chrono::Utc::now().timestamp() + token_resp.expires_in,\n                });\n            }\n\n            let body = poll_resp.text().await.unwrap_or_default();\n            if body.contains(\"authorization_pending\") {\n                continue;\n            }\n            if body.contains(\"slow_down\") {\n                tokio::time::sleep(std::time::Duration::from_secs(5)).await;\n                continue;\n            }\n            ::zeroclaw_log::record!(\n                DEBUG,\n                ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Note)\n                    .with_attrs(::serde_json::json!({\"body\": body})),\n                \"ms365: device code polling raw error\"\n            );\n            anyhow::bail!(\"ms365: device code polling failed\");\n        }\n\n        anyhow::bail!(\"ms365: device code flow timed out waiting for user authorization\")\n    }\n\n    async fn refresh_token(\n        &self,\n        client: &reqwest::Client,\n        refresh_token: &str,\n    ) -> anyhow::Result<CachedTokenState> {\n        let token_url = format!(\n            \"https://login.microsoftonline.com/{}/oauth2/v2.0/token\",\n            self.config.tenant_id\n        );\n\n        let mut params = vec![\n            (\"grant_type\", \"refresh_token\"),\n            (\"client_id\", self.config.client_id.as_str()),","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-tools/src/microsoft365/auth.rs#L267-L303","documentation":"Error \"ms365: device code polling failed\" thrown in zeroclaw-labs/zeroclaw.","triggerScenarios":"Thrown at crates/zeroclaw-tools/src/microsoft365/auth.rs:285 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check network and the polling error; respect the polling interval and retry the flow."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}