zeroclaw-labs/zeroclaw · error · anyhow::Error

ms365: token refresh failed ({status})

Error message

ms365: token refresh failed ({status})

What it means

Error "ms365: token refresh failed ({status})" thrown in zeroclaw-labs/zeroclaw.

Source

Thrown at crates/zeroclaw-tools/src/microsoft365/auth.rs:329

        }

        let resp = client
            .post(&token_url)
            .form(&params)
            .send()
            .await
            .context("ms365: failed to refresh token")?;

        if !resp.status().is_success() {
            let status = resp.status();
            let body = resp.text().await.unwrap_or_default();
            ::zeroclaw_log::record!(
                DEBUG,
                ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Note)
                    .with_attrs(::serde_json::json!({"body": body})),
                "ms365: token refresh raw error"
            );
            anyhow::bail!("ms365: token refresh failed ({status})");
        }

        let token_resp: TokenResponse = resp
            .json()
            .await
            .context("ms365: failed to parse refresh token response")?;

        Ok(CachedTokenState {
            access_token: token_resp.access_token,
            refresh_token: token_resp
                .refresh_token
                .or_else(|| Some(refresh_token.to_string())),
            expires_at: chrono::Utc::now().timestamp() + token_resp.expires_in,
        })
    }

    fn load_from_disk(path: &std::path::Path) -> Option<CachedTokenState> {
        let data = std::fs::read_to_string(path).ok()?;

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. Check the refresh response status; re-run the auth flow if the refresh token is invalid.

When it happens

Trigger: Thrown at crates/zeroclaw-tools/src/microsoft365/auth.rs:329 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/071a1a2391869b29. Report an issue: GitHub.