diff --git a/crates/matrix-sdk/src/client/builder.rs b/crates/matrix-sdk/src/client/builder.rs index 77e5c639f..fa9b17c1f 100644 --- a/crates/matrix-sdk/src/client/builder.rs +++ b/crates/matrix-sdk/src/client/builder.rs @@ -239,8 +239,11 @@ impl ClientBuilder { /// All outgoing http requests will have a GET query key-value appended with /// `user_id` being the key and the `user_id` from the `Session` being - /// the value. Will error if there's no `Session`. This is called - /// [identity assertion] in the Matrix Application Service Spec + /// the value. This is called [identity assertion] in the + /// Matrix Application Service Spec. + /// + /// Requests that don't require authentication might not do identity + /// assertion. /// /// [identity assertion]: https://spec.matrix.org/unstable/application-service-api/#identity-assertion #[doc(hidden)] diff --git a/crates/matrix-sdk/src/http_client.rs b/crates/matrix-sdk/src/http_client.rs index 0d70eeb26..13b4fe25f 100644 --- a/crates/matrix-sdk/src/http_client.rs +++ b/crates/matrix-sdk/src/http_client.rs @@ -125,7 +125,8 @@ impl HttpClient { } trace!("Serializing request"); - let request = if !config.assert_identity { + // We can't assert the identity without a session. + let request = if !config.assert_identity || session.is_none() { let send_access_token = if auth_scheme == AuthScheme::None && !config.force_auth { // Small optimization: Don't take the session lock if we know the auth token // isn't going to be used anyways.