From b5327a7c6d22d0156dc6ed2c9cd90be8ce9815f6 Mon Sep 17 00:00:00 2001 From: Eric Biggs Date: Wed, 22 Jan 2025 21:30:08 -0500 Subject: [PATCH] Update query params for oauth login version bump --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/client.rs | 23 +++++++++++++++++++---- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 26fe999..28c6a50 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1071,7 +1071,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "supabase-auth" -version = "0.10.7" +version = "0.10.8" dependencies = [ "reqwest", "serde", diff --git a/Cargo.toml b/Cargo.toml index 0a7da18..30aa736 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "supabase-auth" authors = ["Eric Biggs"] description = "Supabase Auth implementation following the official client libraries." readme = "README.md" -version = "0.10.7" +version = "0.10.8" edition = "2021" license = "MIT OR Apache-2.0" keywords = ["supabase", "supabase-auth", "authentication", "auth"] diff --git a/src/client.rs b/src/client.rs index 6d8de08..f99efd7 100644 --- a/src/client.rs +++ b/src/client.rs @@ -453,14 +453,29 @@ impl AuthClient { headers.insert(CONTENT_TYPE, HeaderValue::from_str("application/json")?); headers.insert("apikey", HeaderValue::from_str(&self.api_key)?); + let query_params = options.as_ref().map_or_else( + || vec![("provider", provider.to_string())], + |o| { + let mut params = vec![("provider", provider.to_string())]; + + if let Some(ref redirect) = o.redirect_to { + params.push(("email_redirect_to", redirect.to_string())); + } + + if let Some(ref extra) = o.query_params { + params.extend(extra.iter().map(|(k, v)| (k.as_str(), v.to_string()))); + } + + params + }, + ); + let body = serde_json::to_string(&options)?; let response = self .client - .get(format!( - "{}{}/authorize?provider={}", - self.project_url, AUTH_V1, provider - )) + .get(format!("{}{}/authorize", self.project_url, AUTH_V1)) + .query(&query_params) .headers(headers) .body(body) .send()